Density of the Earth's Layers
Density and gravity caused the proto-Earth to cool and settle into four distinct layers. The four layers are, from top to bottom: the crust, the mantle, the outer core, and the inner core. The densities of these layers increase as one goes deeper into the Earth, and the inner core thus has the highest overall density of the four layers.
As stated previously, the Earth formed about 4.5 to 5 billion years ago when the solar system was coming together from space materials and gases. The name for this is coalescence. Since the Earth at this early stage was a big molten ball of lava, the various materials inside it settled down deeper within the Earth according to their relative densities. This means that the denser metals and rocks sank below whatever less dense metals and rocks were around them in this molten, liquid Earth. Over time, this sinking and floating, due to differences in densities, formed an Earth with four main layers. If one could drill into the Earth, one would find the density of the materials increasing the deeper one went inside the planet.
An example of this in everyday life can be found at the supermarket: A bottle of salad dressing needs to be shaken before it can be poured because the oil and water within are separated into two layers. The oil floats above the water due to its lower density. Similarly, the crust of the Earth floated above the other layers due to its lower density as compared with the densities of the other layers.