Comets are formed from the left over material from the formation of the planets in our solar system. The material that did not become planetary remained and formed small lumps of frozen gas and dust where temperatures were cold enough to produce ice. The core of the comet is really nothing more than a very dirty snowball.