This heat that melted the Earth arose from a combination of sources:
Gravitational energy left from the formation of the planet,
Meteor bombardment
Decay of radioactive material trapped in the body of the Earth.