Decay heat
The Earth has two sources of internal heat. One is the heat of accretion, which is heat converted from gravitational energy as the materials which formed the Earth fell together under gravity in the early Solar System. This heat is now estimated to make up about 20% of the total heat flow from the Earths interior. That fact is an indication of how long it has taken the Earth to vent this heat to space.
The other source of heat is the decay of radioactive isotopes of uranium, thorium and potassium, incorporated into the Earth at its accretion. This radiogenic heat is the principal explanation of why the Earths interior is still so hot after billions of years. Without radiogenic heat the Earth would by now have cooled down to the point where the core would probably be solid.
A final factor to consider is the Earths size. The Earth is the largest of the rocky planets in the Solar System, and the thickness of the mantle acts as a blanket. Heat is conveyed to the surface by conduction and by convection, the process that drives plate tectonics. The rate of heat loss governed by the Earths size and composition, balanced against the production of heat by radiogenic decay in the mantle and core and the remaining heat of accretion, explains why the Earths outer core is still molten.