Comets are some of the material left over from the formation of the planets. Our entire solar system, including comets, was created by the collapse of a giant, diffuse cloud of gas and dust about 4.6 billion years ago. Much of the matter merged into planets, but some remained to form small lumps of frozen gas and dust in the outer region of the solar system, where temperatures were cold enough to produce ice.
Find out more from HubbleSite:
HubbleSite and STScI are not responsible for content found outside of hubblesite.org and stsci.edu