Quentin Williams, associate professor of earth sciences at the University of California at Santa Cruz offers this explanation:
There are three main sources of heat in the deep earth: (1) heat from when the planet formed and accreted, which has not yet been lost; (2) frictional heating, caused by denser core material sinking to the center of the planet; and (3) heat from the decay of radioactive elements.
It takes a rather long time for heat to move out of the earth. This occurs through both "convective" transport of heat within the earth's liquid outer core and solid mantle and slower "conductive" transport of heat through nonconvecting boundary layers, such as the earth's plates at the surface. As a result, much of the planet's primordial heat, from when the earth first accreted and developed its core, has been retained.
The amount of heat that can arise through simple accretionary processes, bringing small bodies together to form the proto-earth, is large: on the order of 10,000 kelvins (about 18,000 degrees Farhenheit). The crucial issue is how much of that energy was deposited into the growing earth and how much was reradiated into space. Indeed, the currently accepted idea for how the moon was formed involves the impact or accretion of a Mars-size object with or by the proto-earth. When two objects of this size collide, large amounts of heat are generated, of which quite a lot is retained. This single episode could have largely melted the outermost several thousand kilometers of the planet.
Additionally, descent of the dense iron-rich material that makes up the core of the planet to the center would produce heating on the order of 2,000 kelvins (about 3,000 degrees F). The magnitude of the third main source of heat--radioactive heating--is uncertain. The precise abundances of radioactive elements (primarily potassium, uranium and thorium) are is poorly known in the deep earth.
In sum, there was no shortage of heat in the early earth, and the planet's inability to cool off quickly results in the continued high temperatures of the Earth's interior. In effect, not only do the earth's plates act as a blanket on the interior, but not even convective heat transport in the solid mantle provides a particularly efficient mechanism for heat loss. The planet does lose some heat through the processes that drive plate tectonics, especially at mid-ocean ridges. For comparison, smaller bodies such as Mars and the Moon show little evidence for recent tectonic activity or volcanism.
We derive our primary estimate of the temperature of the deep earth from the melting behavior of iron at ultrahigh pressures. We know that the earth's core depths from 2,886 kilometers to the center at 6,371 kilometers (1,794 to 3,960 miles), is predominantly iron, with some contaminants. How? The speed of sound through the core (as measured from the velocity at which seismic waves travel across it) and the density of the core are quite similar to those seen in of iron at high pressures and temperatures, as measured in the laboratory. Iron is the only element that closely matches the seismic properties of the earth's core and is also sufficiently abundant present in sufficient abundance in the universe to make up the approximately 35 percent of the mass of the planet present in the core.
The earth's core is divided into two separate regions: the liquid outer core and the solid inner core, with the transition between the two lying at a depth of 5,156 kilometers (3,204 miles). Therefore, If we can measure the melting temperature of iron at the extreme pressure of the boundary between the inner and outer cores, then this lab temperature should reasonably closely approximate the real temperature at this liquid-solid interface. Scientists in mineral physics laboratories use lasers and high-pressure devices called diamond-anvil cells to re-create these hellish pressures and temperatures as closely as possible.