A planetary nebula is an expanding, glowing shell of hot gas (plasma) that is cast off towards the end of a low-mass star's life. Despite the name, they have nothing to do with planets, and were so named because early astronomers thought they looked a bit like planets through a small telescope.
Low-mass stars turn into planetary nebulae towards the end of their red giant phase. At that point the star becomes highly unstable and starts to pulsate. The outer layers are ejected by the resulting stellar winds. Planetary nebula are relatively short-lived, and last just a few tens of thousands of years.
As the outer layers drift away from the star, the remaining core shines brightly and is very hot (100,000°C+) - the core is now a white dwarf star. The ultraviolet radiation pumped out by the white dwarf causes the ejected outer layers to glow - the planetary nebula.
Over time, the enriched material from the planetary nebula is scattered into space and will be used for future generations of stars.