For all the blather that has happened, NOBODY has done much of anything to answer the topic title question.
I can blather, too, though I'm sort of short-winded. But the following won't be blather:
Some 4,570 million years ago or so, the early sun had a disk-shaped nebula of dust and gas. The gas was largely hydrogen, helium, carbon monoxide, carbon dioxide, methane, and a few inert gases. The dust was largely oxides and silicates of metals: calcium, magnesium, aluminum, iron, manganese, etc. Iron was pretty prominent because it's the ultimate "ash" of a supernova - iron-56 is at the bottom of the energy well of all atomic nuclei.
As the sun started really heating up, most of the dust and gas got blown off into space. A good fraction of the dust, though, suffered from "static cling" and stuck together into BB to marble-sized grains. These collided gently under gravitational forces until there were a BUNCH of objects about the size of present-day asteroids -100 to 1000 km across or so. These got hot as they did so from kinetic energy being converted to heat and from the heat of radioactive decay of aluminum-26 and the like.
The molten iron (and other, less abundant heavies) drained to the middle of these planetesimals. The planetesimals collided until they built up planet-sized bodies, which were essentially molten due to all the kinetic energy that went into their formation. Iron and other heavyweight stuff drained to the centers; a slag of silicates and oxides floated to the exteriors.
We know this partly because the inner planets have densities of about 5.5 g/cc. The (silicate) rocks up on top have densities below 4. Something in the middle obviously is denser than 5.5, and iron is 1) nearly 8 g/cc and 2) abundant enough in stardust to be that material. We know that last bit because we have the meteorites and the dust from space missiond to analyze to show it.
Edited by Coragyps, : tpyos