Both planets and moons move around the Sun, which is the central, most massive, most influential and attractive body in the Solar system. The moons or natural satellites are kept in orbit by the gravitational attraction between the satellite and the celestial body or planet it orbits.
The Earth has a much greater mass than the Moon. The Moon orbits planet Earth due to the gravitational pull of Earth. The Earth moves in an elliptical orbit around the Sun due to the gravitational attraction of the Sun. While the Moon is orbiting the Earth, both the Moon and Earth move around the Sun. The same applies for artificial satellites, and for other planets and their moons or natural satellites.
The question of the stability of planetary orbits, or why planets “don’t pull each other off course”, is related to topics and disciplines such as the stability of the solar system, the n-body problem, gravitation, and celestial mechanics.
Gravity, or gravitational attraction, provides the force needed to maintain the stable orbit of two or more planets around a star and also of moons and artificial satellites around a planet.
Newton’s law of universal gravitation states that every point mass attracts every single other point mass by a force acting along the line intersecting both points. The force is proportional to the product of the two masses and inversely proportional to the square of the distance between them.
This law can be expressed as:
Newton’s law applies to all celestial bodies. The planet Jupiter is attracted by the Sun, as is planet Saturn, and Jupiter and Saturn attract each other. The Sun’s influence is the most dominant one because the mass of the Sun represents approximately 99.8% of the mass of the solar system.
Within a planetary system, planets, dwarf planets, asteroids and other minor planets, comets, and space debris orbit the system’s barycenter in elliptical orbits.
The general problem of predicting the individual motions of a group of celestial objects interacting with each other gravitationally is called the n-body problem.
For mass mi with position vector qi, the n-body equations of motion (summing over all masses) can be written as:
The general n-body problem is difficult to solve analytically. It is mostly solved or simulated using numeral methods and power series solutions.
Investigating the stability of the solar system led scientists and mathematicians in the 18th century to create a new method of calculation in celestial mechanics known as the method of perturbations.
The orbits and motions of the planets Jupiter and Saturn, mentioned in this question, have a significance in the history of astronomy, and have been specifically studied and explained by Laplace at the end of the 18th century.
Laplace presented a memoir on planetary inequalities in three sections, in 1784, 1785, and 1786. This dealt with the identification and explanation of the perturbations now known as the “great Jupiter–Saturn inequality”. Laplace solved a longstanding problem in the study and prediction of the movements of these planets, showing by general considerations, that the mutual action of two planets could never cause large changes in the eccentricities and inclinations of their orbits; then, that peculiarities arose in the Jupiter–Saturn system because of the near approach to commensurability of the mean motions of Jupiter and Saturn.
The two planets’ mean motions is very nearly equal to a ratio between a pair of small whole numbers. Two periods of Saturn’s orbit around the Sun almost equal five of Jupiter’s. The corresponding difference between multiples of the mean motions, (2nJ−5nS), corresponds to a period of nearly 900 years, and it occurs as a small divisor in the integration of a very small perturbing force with this same period. As a result, the integrated perturbations with this period are disproportionately large, about 0.8° degrees of arc in orbital longitude for Saturn and about 0.3° for Jupiter. With the help of Laplace’s discoveries, the tables of the motions of Jupiter and Saturn could at last be made much more accurate.
Moreover, Laplace was able to explain Claudius Ptolemy’s astronomical observations in Antiquity to about one minute of arc, with no need for additional terms in the calculations. Hence he demonstrated that Newton’s law of universal gravitation was enough to explain the motion of the planets all over known history.
Laplace and Lagrange showed that the semi-major axes of the planets undergo small oscillations, and do not have secular terms, which represented the first significant result in explaining the Stability of the Solar System.
The next generations of humans will not need to worry about planets colliding into each other or pulling each other off course.
Computer simulations and studies have shown that in the next few hundreds of millions of years the motions and orbits of the planets will mostly remain regular and stable, with the possibility of appearance of chaotic orbits after tens of millions of years.
It is to be noted that in less than five billion years it’s possible that collisions between planets might take place, or also ejections of planets out of the solar system.