Basically the Earth is layered because of gravity. The earth formed in the molten state. The liquid iron which is very dense fell to the center. The rest of the earth is made up of silicate materials with SiO2 being the main component.
hope this helps!