They shall fear You as long as the sun and moon endure, throughout all generations. (Psalms 72:5)
Genesis 1:31, 8:22
2 Peter 3:13
God is an excellent designer! When He created all things, they were perfect Genesis 1:31; Deuteronomy 32:4. There was no death, bloodshed, suffering . . . and no homework! The world really was perfect. But it wasn’t just the world that was perfect—everything was, including the sun. It was perfectly designed by God. It has been consistently producing light and heat for earth since its creation on Day Four (“the greater light to rule the day”). There is no reason to assume that it will not continue to perform these duties until the end.
Keep in mind something that happened in the past that affects the whole of creation (Romans 8:20–22: the Curse. When Adam sinned against God, God cursed the ground and the animals and sentenced man to die Genesis 3. The Curse affected everything Romans 8:22. This would also affect the sun. This is why we will eventually need a new heavens and a new earth Isaiah 66:17–22; 2 Peter 3:13; Revelation 21:1.
But until then, as long as the earth endures, God promised that day and night, cold and heat, seedtime and harvest, and winter and summer shall not cease Genesis 8:22. So the sun, which is vital for this, will continue to do its created duties until the end.