Hello, the earth core is about 5430 degrees C or approx 5700 Kelvin. This residual temperature comes from when the earth was a ball of liquid magma.
On the other hand the temperature of the sun varies from the surface to the core. The temperature of the surface is also about 5800 Kelvin. The core of the sun is instead supposed to be about 10 millions Kelvin (10^7 K).
At this elevated temperature nuclear reactions occur like the fusion of hydrogen to produce helium. This is the main reaction that produces the energy that gives the sun its luminosity (and its vital for our life on the earth).