The idea behind a gravity assist is to use a planet's motion to accelerate a satellite. For example, a satellite heads toward Jupiter -- in the process, it accelerates because it is "falling toward" Jupiter. Then, it passes fairly close to the planet and starts speeding away from it. However, at that point, the satellite starts slowing down because gravity is pulling it back toward the planet.
From that description, it would seem like the net effect of gravity assist is zero -- the satellite gains speed as it falls toward the planet but then loses it as it heads away. The thing that makes gravity assist work is the fact that the planet is in motion in its orbit. Jupiter, for example, is about 500,000,000 miles (806,000,000 kilometers) away from the sun, which means that the circumference of its orbit is 3,140,000,000 miles (5,060,000,000 kilometers).
Jupiter travels that distance in about 12 years, so it is moving through space at about 30,000 mph (48,000 kph). If the satellite is moving in the same direction as Jupiter in its orbit, it can actually increase its speed by 30,000 mph! That is a huge speed increase, and it's completely free.
The problem with gravity assist is that you have to wait for the planets to line up correctly for it to work. That is why missions have to fly within certain time windows.
Here are some interesting links: