It's my understanding that Earth's core is hot and molten because of the high pressure from gravity compressing the planet's mass towards the center. How does this heat reconcile with thermodynamics, meaning, would it be possible for all the heat to bleed away into space through infrared radiation etc., such that the Earth eventually had about the same mass in about the same configuration, but was instead cold at the core? Or would it always be the case that as long as the planet holds together, it will be hot at the center due to gravity?
How are these two processes reconciled, meaning, why would there eventually be a "heat death" of the universe so long as there is gravity making masses come together into a form that causes local hot spots (or in larger cases, new suns)? Wouldn't the planet have to fly apart to get much colder, and why would it do that? Is it possible for the mass to stay together while all the energy dissipates (ie temperature eventually goes to zero K)?
[I'm not a physicist, so if I'm way off the rails, please help me understand what's really going on.]