Comets originated in the earliest history of the Solar System. An early high energy stage pushed the volatile constituents (mostly water) and dust out and away from Sun and into the outermost Kuiper Belt and Oort Cloud. Billions of comets, possible up to a trillion, formed and reside there in stable orbits. When a comet orbit is changed into an elongate ellipse, the comet travels through through the inner Solar System for roughly 500 orbits before the comet loses it's volatiles. Ultimately, it may become a meteor shower or collide with a planet or the sun. Comet impacts, although probably rare on a human time scale, are, in fact, very common and potentially much more dangerous than asteroid impacts. The rate of comet impacts is unknown, but we've had two in the past couple decades involving collisions with Jupiter. Some of the Earth's major impact sites may be caused by comets rather than asteroids as is generally believed. Unless a piece of the impactor is preserved, you can't really tell the difference. As such, comets may constitute a significant portion of the Earth's water.