Why do the objects settle in different layers?

How does the amount of sugar change the density of liquid?