How did Earth's layers develop?
By a process called differentiation.
Differentiation is thought to occur in all planets, whereby denser elements sink to the core of the planet and lighter elements move upward. Once this process is completed, the planet takes on a layered look. See the Wiki entry.