The planetary nebula phase is a final stage in a low-mass star's life. During this phase, the star sheds its outer layers. This creates an expanding, glowing shell of very hot gas. Despite the name, they have nothing to do with planets. They got this name because astronomers using small telescopes long ago, thought they looked a bit like planets.
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. This produces strong stellar winds which throw off the outer layers of the star.
The outer layers drift away from the star leaving a small hot, bright core behind, called a white dwarf. The white dwarf gives of ultraviolet radiation which lights up the layers of gas around the star.
Over time, the material from the planetary nebula is scattered into space. Eventually it will form part of the clouds of dust and gas where new stars form.
Planetary nebula last just a few tens of thousands of years. This is short compared to the thousands of millions of years which low-mass stars shine for. Our Sun is a low-mass star and will produce a planetary nebular in about 5,000 million years time.