The Earth is layered because of the difference in the density and the pressure experienced by the elements. The denser layers tend to be closer to the center and the lighter layers float on the top. The differences in the pressure experienced by these layers also keeps them separated. The pressure experienced by the center of the Earth is greater than the upper layers, and hence, the core is in liquid form because the pressure is not enough for it to remain in the solid state.
This led to the layering of the Earth's surface.