|MadSci Network: Earth Sciences|
That's a very good question. The answer is that the solid inner core IS hotter than the liquid outer core. Your question should be "Why is the inner core of the Earth solid, even though it is hotter than the liquid outer core?"
For almost all materials, the solid is denser than the liquid, because it is better packed, and has less random thermal motion in it (gas is even less dense and more random). The most familiar substance we know, water, is very strange. It's solid is less dense, so ice floats on water (icebergs, pond ice, ice cubes in drinks etc). Just about everything else doesn't do this.
If you take a liquid that is near to its freezing point, and put it under high pressure, you squeeze it into the solid state at a tempreature where at normal pressure it would still be liquid. So it is with the Earth's core The whole thing is close to the liquid/solid transition temperature. (No coincidence, either - see later). The higher pressure near the middle means that the inner core is solid, and the outer core is liquid.
For some background on the Earth, see my earlier answer to "How hot is the centre of the Earth and how do you know?" in the archives.
Two more points: The reason why the Earth's core is close to the melting point is that it was probably hotter earlier, but is slowly cooling down. At the freezing point, extra energy is released as the molecules pack into tighter formation. This "Latent Heat of Crystallisation" means that systems with solid and liquid co-existing spend a long time at the solid/liquid temperature, even if you keep heating or cooling them.
Try an experiment with a glass of water and lots of ice cubes. Put it in a warm place and measure its temperature every 20 minutes or so. Draw a graph of temperature against time. It should look like this:
| * * * | * * | * * | * | * * | * | * | * 0|* * * * * * * * | ^last ice melts | | | | *___________________________________________________ Time -->If you try the same thing in a freezer, it should go the other way (use a plastic glass and gloves).
Last point: The Earth was probably never formed from a piece of the Sun. Rather, the Sun and all the planets were formed at the same time from interstellar gas and dust. As the sun began to get hot, the gas was burned and blown away from any 'small' planets 'near' to the Sun. So Mercury, Venus, Mars, and Earth are made mostly of rock (recrystallised dust) and Jupiter, Saturn, and Neptune were big enough and far enough from the proto-Sun to hold onto their gas.
Try the links in the MadSci Library for more information on Earth Sciences.