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.

cross section shows Earth's structure
CROSS SECTION shows Earth's structure.

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.

Those experiments provide a stiff challenge, but our estimates for the melting temperature of iron at these conditions range from about 4,500 to 7,500 kelvins (about 7,600 to 13,000 degrees F). As the outer core is fluid and presumably convecting (and with an additional correction for the presence of impurities in the outer core), we can extrapolate this range of temperatures to a temperature at the base of Earth's mantle (the top of the outer core) of roughly 3,500 to 5,500 kelvins (5,800 to 9,400 degrees F) at the base of the earth's mantle.

The bottom line here is simply that a large part of the interior of the planet (the outer core) is composed of somewhat impure molten iron alloy. The melting temperature of iron under deep-earth conditions is high, thus providing prima facie evidence that the deep earth is quite hot.

Gregory Lyzenga is an associate professor of physics at Harvey Mudd College. He provided some additional details on estimating the temperature of the earth's core:

How do we know the temperature? The answer is that we really don't--at least not with great certainty or precision. The center of the earth lies 6,400 kilometers (4,000 miles) beneath our feet, but the deepest that it has ever been possible to drill to make direct measurements of temperature (or other physical quantities) is just about 10 kilometers (six miles).

Ironically, the core of the earth is by far less accessible more inaccessible to direct probing than would be the surface of Pluto. Not only do we not have the technology to "go to the core," but it is not at all clear how it will ever be possible to do so.

As a result, scientists must infer the temperature in the earth's deep interior indirectly. Observing the speed at which of passage of seismic waves pass through the earth allows geophysicists to determine the density and stiffness of rocks at depths inaccessible to direct examination. If it is possible to match up those properties with the properties of known substances at elevated temperatures and pressures, it is possible (in principle) to infer what the environmental conditions must be deep in the earth.

The problem with this is that the conditions are so extreme at the earth's center that it is very difficult to perform any kind of laboratory experiment that faithfully simulates conditions in the earth's core. Nevertheless, geophysicists are constantly trying these experiments and improving on them, so that their results can be extrapolated to the earth's center, where the pressure is more than three million times atmospheric pressure.

The bottom line of these efforts is that there is a rather wide range of current estimates of the earth's core temperature. The "popular" estimates range from about 4,000 kelvins up to over 7,000 kelvins (about 7,000 to 12,000 degrees F).

If we knew the melting temperature of iron very precisely at high pressure, we could pin down the temperature of the Earth's core more precisely, because it is largely made up of molten iron. But until our experiments at high temperature and pressure become more precise, uncertainty in this fundamental property of our planet will persist.