I think comets formed at the edge of the huge molecular gas cloud that collapsed to form the solar system. They are mostly ice and have crazy orbits. They fly in toward the sun at mad angles and shoot back out again toward the edge of the solar system. Sometimes they plunge straight into the Sun and burn up. There is a satellite looking at the sun that has seen many comets do this.