Comets are balls of leftover rock and ice that were originally part of a nebula formed when a star exploded into a supernova. These balls didn't form into planets when most of the material in our nebula merged together, about 4.5 billion years ago. Instead, the comets kept on circling around the Sun on their own.
Most comets come near Earth just once and then shoot off into outer space, going out beyond our solar system for thousands of years before they circle back again. A few comets have smaller orbits, staying mostly within our solar system. Some cross Earth's orbit every year, like Comet Swift-Tuttle. We see Halley's Comet once every 75 years or so.
When a comet gets close enough to the Earth, some of the smaller rocks that are associated with that comet get sucked into Earth's gravity and come falling down to the Earth. We call these meteors. Some comets end up hitting other planets or hitting the Sun, or they come close enough to Jupiter to be affected by Jupiter's gravity and whipped out of the solar system like rocks in a slingshot.
When comets get nearer to the Sun, the heat of the Sun warms them up and melts off some of their ice. After about 800 visits near the Sun, the comets are just balls of rock. Many of the asteroids near Earth are old dead comets.
There are probably comets going around other stars as well as our own, but they are too small for our telescopes to see yet.
Cool stuff we've been enjoying: Looking for birthday gifts? Check out these new Chromebooks - all the computer you need for only $229.00!. Then study in peace with these Beats wireless headphones - for the exact same price! When you're done, show off your presentation or watch a movie with this excellent smartphone projector for only $39.99!