They disperse life-giving elements cooked at the star's core, which are then used in the creation of successive generations of stars, planets and even life itself. The elements that make up our bodies are in reality the remains of a once-flourishing star. In essence, stellar death is just an example of interstellar recycling.
Nothing goes to waste.
Each generation of stars recycles a significant amount of material back into the reservoir of gas from which new life can form. That's why astronomers study planetary nebulae. They tell us the story of our own Sun's eventual fate and shed light into how the cosmos came to be.