Despite the name, these objects have nothing in common with planets. However, they seem to represent the likely final phase of the Sun's existence as a star. It is estimated that there are about 10,000 planetary nebulae in the Milky Way, our galaxy, so they are a relatively common, although short phase (approximately 25,000 years) of the stellar life cycle.
Planetary nebulae form when a star can no longer support itself by fusion reactions in its center. The gravity from the material in the outer part of the star takes its inevitable toll on the structure of the star, and forces the inner parts to condense and heat up. The high temperature central regions drive the outer half of the star away in a brisk stellar wind, lasting a few thousand years. When the process is complete, the remaining core remnant is uncovered and heats the now distant gases and causes them to glow, forming the nebulae we can observe.