Why is the earth made up of different layers?
The Earth is huge relative to us. It is not even close to a heterogenious composition. The deeper you go, the higher the pressure gets from the weight of the ground on top of that point.
With higher pressure comes higher temperature. At around the mantle, under the crust (20-30mi deep) the temperature is much higher than the crust but the mantle is still fairly solid.
The temperature becomes so high when you get deep enough that the outer core is mostly liquid iron and nickel. The pressure at the inner core is so high that the iron and nickel are compressed into a solid.
Fun fact, the solid inner core has a radius about 70% of the moon's.