What caused the formation of the earth's layers?
At the time of formation by accretion, Earth was not homogeneous. As gradients of temperature and pressure increased with distance from the surface, the interior was stabilized by forming layers.
Even now, the classification of layers is not final. It is changing into 'narrower than before' classification, with advances in technology in seismology ( study of propagation of earthquake waves in the Earth's interior).
Core is more stable than the other outer layers. Perhaps, the very slight changes in the extreme temperature and pressure, at great depths, are not detectable from the surface.