Gravitational Dynamics
I. Tidal heating and tidal locking
Almost all of the moons in the solar system are, like our own Moon, tidally locked to their planets, which means they are in circularized orbits and rotate at the same rate as they revolve, keeping the same side facing the planet. This is because of the tidal gravity of the planet, such that when a moon is not in a circular orbit, the changing distance to the planet causes the shape of the moon to be warped in a process like kneading dough. This heats the interior of the planet (just as kneading dough will somewhat warm the dough), and the release of gravitational energy results in circularizing the orbit. If the moon's rotation is not synched to its orbit, the "football shape" created by tidal forces will get turned slightly away from alignment, and the resulting gravitational torque on the "point" of the football is what gradually changes the rotation rate until it synchs with the orbit.

However, some moons, like Io and Europa around Jupiter, show signs of recent interior heating (they have active magma and volcanic activity, though in Europa the "magma" is liquid water), even though they are tidally locked. It must be that perturbations from the other Galilean moons occasionally alter their orbits, and while they are re-circularizing, their interiors get tidally heated. This is the only way Io and Europa could have avoided cooling into solid rocks by now.

II. Three-body problems
This kind of orbit perturbation and tidal heating is an example of what are called three-body problems in physics, and in the case of an inverse-square force like gravity, three-body problems are notoriously difficult because they result in chaotic orbits in all but a few special cases. One important special case is when the three masses are arranged in an equilateral triangle. To see that this case allows all three masses to be in circular orbits with the same period, write the acceleration of gravity in the useful form:
g = r*Gm/D^3
where g and r are vectors (r is the vector displacement to the mass m that is causing the gravitational acceleration), and D is the distance to m. Choose one of the masses as the origin of the coordinate system, and then there are two r vectors of interest, one to each of the other masses. Convince yourself that the total acceleration of gravity on the mass in question equals GM/D^3 times the vector displacement to the center of mass, where M is the total of all three masses. This expression works for all three masses independently, so they all experience and acceleration toward the center of mass. If they are all put in circular orbits around the center of mass, that acceleration equals omega^2 times the distance to the center of mass, where omega^2 is the same for all three masses. This means they all have the same orbital period, equal to 2pi/omega, and maintain the equilateral triangle as they orbit.

III. The reduced three-body problem and Lagrange points
However, with any orbit, we must test its stability. It turns out this orbit is not stable unless there is a great deal of contrast among the three masses. In the case where one of the masses is negligibly small, like an asteroid or human-made satellite, the three-body problem reduces to what is called the "reduced three-body problem", which is much simpler because we can take the center of mass to be on the line between the two larger masses, and the orbit of those two masses is just the usual simple two-body problem If we further take those orbits to be circular, and introduce the third body of negligible mass, we have the familiar situation that leads to what are called "Lagrange points."

Lagrange points are places where a test particle could follow circular orbit with the same period as the two large masses. This means if we go into a frame that rotates with the orbital revolution, the two large masses become stationary, and the Lagrange points are points of zero effective gravitational acceleration (meaning the acceleration from both masses plus the fictitious centrifugal acceleration). There are 5 such points, denoted L1, L2, L3, L4, and L5. The L4 and L5 points correspond to the equilateral triangle we already discussed, and the other three lie along the line between the two large masses, two bracketing the smaller of the two masses (L1 being between the masses, L2 being beyond the smaller mass), and one (L3) is beyond the larger mass. You can easily google a picture of what the Lagrange points look like.

The orbital stability around the Lagrange points is nontrivial, as they are generally unstable yet we use L1 and L2 for satellites, and L4 and L5 exhibit the trojan asteroids around Jupiter. But satellites and L1 and L2 require "station keeping" (small rocket engines capable of stabilizing their orbits around L1 or L2), and trojan asteroids are not pulled toward L4 and L5, they scatter widely around those points and orbit around them (in the co-rotating frame).

IV. Effective potential
One way to understand the lack of stability of the Lagrange points is to notice that the effective (gravity plus centrifugal) acceleration depends only on position (and also happens to be curl free), which means it can be expressed as a gradient of an effective potential (and this also means the kinetic energy in the co-rotating frame is path independent and changes in response to changes in the effective potential). So we can create a kind of contour plot, or landscape, for the effective potential, and low points in such a landscape would be stable equilibria. But L1, L2, and L3 are saddle points, and L4 and L5 are actually maxima, so none are stable in the traditional sense. However, the weak gradients at L1, L2, and L3 make station keeping easy (especially since they are only unstable in one direction), and when satellites or asteroids wander away from L4 and L5 (as they inevitably do), the coriolis force acting on their motion will turn them into a kind of orbit around L4 and L5, much like the coriolis force on Earth turns the winds to circulate around low and high pressure centers. So the trojan asteroids exhibit a kind of dynamical stability, where they are not close to L4 and L5 but instead have wide "tadpole" orbits around them.

V. Horseshoe orbits and near-Earth asteroids
If a test particle gets far enough away from an L4 or L5 point, it will not orbit the Lagrange point, but instead will enter into a much wider orbit (in the co-rotating frame) that goes all the way around the larger mass and approaches the smaller mass from the other side. At this point it is in some sense "repelled" by the smaller mass, which is a strange thing for an attractive force to do but this is the usual paradox of the gravity when in orbit around a distant large mass-- any attempt to propel the object forward in the direction it is going will cause it to fly out and slow down, and any attempt to impede its motion will cause it to fall inward and speed up. This results in the "repulsion" from the smaller mass as the test particle approaches it, and causes the horseshoe orbit to reverse direction (in the co-orbiting frame, in the inertial frame these are always very close to the same orbit as the smaller mass). For asteroids near Earth, they approach Earth but are then turned around (fortunately) by these horseshoe orbits. However, that only accounts for the gravity of the Sun and the Earth-- the other planets can cause perturbations that remove asteroids from horseshoe orbits and can put them into orbits that could collide with Earth. Indeed, it seems there is a rather nasty collision with a "near-Earth asteroid" about every 50-100 million years, as seen in fossil records of mass extinctions. Had this not been a very long time, we could not be here. Still, NASA monitors such asteroids, because they are aware of the "Anthropic princple"-- which means we might juat have been very lucky so far. (Indeed it would be an interesting question that I have never seen addressed as to whether the latest absence of severe asteroid hits has been unusually long compared to our history, since intelligent life would more likely develop during such a hiatus).

VI. Comets
Comets are essentially asteroids that spend most of their time so far from the Sun that ices persist on their surface. Then when they get close to the Sun, the ices evaporate (called sublimation), creating a mist of vapor and dust around the comet (called a coma). The individual atoms and molecules get combed out by the solar wind once they get ionized (and the solar wind is at high speeds of hundreds of km/s), while the dust particles experience a much weaker force from sunlight, which coaxes them away from the comet and creates the visible tail that makes comets so famous. This tail is only seen when the comet is closer to the Sun than about Jupiter, since that is the "frost line" where ice sublimes.

The orbit of visible comets must be highly eccentric in order to survive at large distance from the Sun for long times, yet still get close enough to make a tail. Most comets never make tails at all, they simply orbit the Sun beyond Neptune in a region called the Kuiper belt. These have orbits less than 200 years and are called short-period comets. But there is another population of long-period comets, called the Oort cloud, that have highly elliptical orbits that are not constrained to lie in the ecliptic plane with the planets and the Kuiper belt, as these comets have been strongly perturbed in their history. When we see a long-period comet come close to the Sun, it could be on an orbit of thousands, or even hundreds of thousands, of years, so we do not expect any record of ever having seen that comet before. Short period comets, like comet Halley, have a long historical record, and played a key role in verifying the predictions of Newtonian gravity. Comets also have a history of being interpreted as harbingers of doom, such as the comet in 1066 that presaged the disaster for the Anglo-Saxons that was the Battle of Hastings. Of course, this was not a distaster for the conquering Normans, and we now know that comets are too far from Earth to have any significance here other than putting on a remarkable otherwordly show. On the other hand, in the rare times when a large comet does impact the Earth, it is indeed a harbinger of doom after all!

VII. Gravitational assists and Hohman transfers
We use some of the detailed properties of orbital mechanics to create more efficient ways of navigating the solar system. A gravitational assist, or "slingshot", is when we use the gravity of a moving planet to add or remove kinetic energy from a human-made rocket. The idea there is similar to when a tennis player strikes a ball with a moving racket-- in the frame of the racket, the ball comes in at the combined speed of the ball and the racket, and the strings of the racket simply reverse the direction of that velocity. When transforming back to the reference frame of the tennis court, reversing that velocity amounts to adding up to twice the speed of the racket to the ball. Similarly, a planet can add up to twice its speed to a rocket whose direction is reversed by the planet's gravity, or the planet can subtract up to twice its speed if the rocket is overtaking the planet. That represents a significant energy savings to not have to do that with an onboard rocket, so this kind of maneuver is routinely done (sometimes multiple times and with multiple planets, including our Moon). Obviously it is an intricate calculation to emerge with precisely the desired velocity.

Another type of gravitational assist involves firing rockets on a satellite at a time when the satellite's speed has been increased by gravity, since the greatest change in kinetic energy for a given added impulse comes when the speed is highest (change in kinetic energy is velocity dotted with impulse, for any nonrelativistic motion, because delta p^2/2m = p/m dot delta p ). For example, the Parker probe is altering the apogee of its elliptical orbit around the Sun by firing rockets when the probe is closest to the Sun, since the Sun's gravity makes the probe fastest at that point and each rocket firing represents a given impulse, delta p.

Another trick that space navigation employs to use the least energy (though not necessarily the least time) is the Hohman transfer orbit. This amounts to placing a rocket into an elliptical orbit that spans the gap between the orbit of the Earth and some other planet, like Venus. The rocket is launched in the direction of Earth's orbit if the desired target is farther from the Sun, or against the direction of Earth's orbit if the target is closer to the Sun (such as the Parker probe). It seems likely that any eventual human trip to Mars will require a heavy rocket that will need to maximize energy efficiency, and a Hohman transfer orbit for such a rocket would take, according to Kepler's law, roughly (2.5/2)^(3/2) = 1.4 years. The same holds for the return, and one must be sure that Earth will be in the right place on the return, so the better part of a year must be spent on Mars waiting for that. Hence a maximally efficient trip to Mars will require about three and a half years, and surviving in space for such a timespan is one of the many reasons this may be an impossible task. NASA has already done many impossible things, so I don't rule it out, but it will be tough. It seems possible the first human to Mars will be someone willing to make it a one-way trip, and NASA would never do that, so it might come out of many tries from the private sector, we will see. Or you will, anyway!

All of these tricks are used, and indeed the "Grand Tour" Voyager mission took advantage of all of them-- gravitational assists, transfer orbits, and perfectly times rocket bursts. The planets only suitable align for this once every 175 years, so it was quite fortunate the time came just as our technology became capable of it-- we could have faced a long wait.