They shall fear You as long as the sun and moon endure, throughout all generations.(PSALMS 72:5)
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.