4.6 billion years into its existence the lava at the core of the Earth is still not freezing. The internal heat of the Earth is due mainly to four sources. 1) About 10,000º Celsius of heat generated at the time of Earth’s formation is still not discharged in the space. 2) A few crore years after the Earth’s formation a space object the size of Mars collided with Earth and the impact generated immense heat. Our moon is formed of debris resulted out of this massive collision. 3) Internal flow of liquids in the Earth generate heat out of friction with substances they come in contact with. 4) The core of the Earth is rich with radioactive substances like uranium, thorium and potassium-40 which generate heat while decaying.
On one hand the already cooled down 6 to 40 kilometers thick external crust blocks internal heat from coming out, and on the other hand the flows of liquids and decay of radioactive substances below the crust constantly generate heat. As a result the core heats up all the more. This situation is favorable to the life on Earth though. If the Earth went the same way of the now cold Mars then it would lose electrical flows at the core and in turn magnetic fields. Once the protective shield vanishes, Sun’s intense radiation would kill the life on Earth.