Why would the sun’s energy be taken away?

It's the impending and inevitable heat death of the universe... several billions of years away...

Our nearest star, Sol, will grow cold well before then.

But even that is estimated to take trillions of years after it runs out of hydrogen for fusion.

I think you're off by about 90 orders of magnitude for the actual heat death