To understand the answer to this question, it is helpful to learn some amazing facts about Jupiter. It is the largest planet in our solar system. In fact, it is twice as large as all of the other planets put together. Jupiter's width is 11 times that of Earth. Jupiter has over 300 times the mass of Earth and 2.5 times the combined mass of all the other planets in the Solar System.
This is important because mass is related to gravity. The greater the mass of an object, the more gravitational force it exerts on other objects. Its incredibly strong gravitational force causes Jupiter to have such a profound influence on the orbits of comets and asteroids.
Jupiter has been known as the "vacuum cleaner of the solar system" because its gravity attracts and absorbs comets and asteroids that come too near. There is speculation that Jupiter's gravitational influence prevented the asteroids in the asteroid belt between Mars and Jupiter from coming together and forming a planet.
Jupiter's gravity often affects the orbits of comets and asteroids by grabbing them and radically altering their orbits. Jupiter has been called Earth's protector because its gravity deflects moving objects in space that might otherwise strike Earth. There is also evidence, however, that sometimes Jupiter grabs comets and alters their orbits and send them streaking towards Earth. For instance, in 1770, Jupiter's gravity altered the direction of a comet speeding through the solar system and sent it in Earth's direction. This comet, which became known as Lexell's comet, came within a million miles of Earth. This is closer than any other comet in recorded history. As it appeared in the sky in 1770, the comet and its tail were four times the size of the full moon.