Actually, that question was one of the great scientific mysteries of the previous century. The continued shining of our Sun over the eons was impossible to understand or explain in the 1800s and early 1900s. There was also no good and reasonable scientific explanation for the creation of our Moon, which led some scientists to conclude that the Moon does not exist, and by analogy, that the Sun does not shine. However, it is nearly impossible to conclude that the Sun does not shine.
With the help of Albert Einstein's theories of Relativity (E=mc²) and the better understanding of atomic nuclear reactions, it became clear that the Sun shines as a black body with the ongoing heat source being the continual conversion of matter into energy via nuclear fusion of Hydrogen into Helium. So the Sun does shine after all. (And the Moon does also exist, but that is a different story.....)