An exploding star is a supernova, or the process by which a star transforms into a different kind of body. It can become a dwarf star, a quasar or a pulsar. The end result of the transformation can even result in what is known as a black hole in space where even light cannot escape the force of the gravity created by the transformed object within such a black hole in space.
The cause of the supernova is the consumption of most of the hydrogen fuel that produces a chain reaction that creates heat, light and radiation which is emitted during the useful life of the star. In regard to our own Sun, the light, heat and radiation from our Sun created life on our planet. In so doing, mass is transformed into energy. The same is true for all stars within the universe. However, life might not be created on the planets that obit most other stars.
After millions of years the lost mass of the star results in a lower gravity which, in effect, causes the chain reaction to increase and thus cause the mass of the star to decrease. When the gravity of the star can no longer contain that chain reaction the star will explode with one final burst of energy. So too, a relatively small star will become a hollow shell and simply collapse on itself after its hydrogen fuel is depleted.
The explosion itself causes the sudden release of gamma radiation that can destroy all of the planets that orbit the star. That gamma radiation can travel hundreds of light years, together with the light that is released. The end result being that a star might have gone supernova a long time ago but just now be seen by people here on Earth. For example. if the star is 100 light years away and explodes, we will see that explosion about 100 years after the event occurs.
Believe it or not, star supernovas are common events because there are hundreds of billions of stars within the universe. As a matter of fact, just one galaxy can contain a billion or more stars that orbit around the center of the galaxy. It is now believed that each galaxy contains a black hole in its center, the gravity of which is so powerful as to retain objects in orbit around the black hole that are as far away as 150 light years. Our own galaxy is about 200 light years in diameter. Yes, and the location of our own Solar system is near the outer edge of the galaxy.