Answer:
The earth has different layers because as it formed, the lighter parts (like continental crust) floated to the surface, and the really heavy parts (like iron and nickel in the core) sank to the middle. It is just like when you mix oil and water: the oil will float to the surface because it is lighter (or less dense) than the water.