When two bodies orbit around each other in space, we know exactly what happens. The bodies trace out conic sections, they do so in accordance with Kepler’s laws, and that’s it, more or less.
When three or more bodies orbit around each other in space, things can be more complicated. In the general case, no explicit formula for the orbits exists, and we have to rely on numerical simulations. As the first two animations illustrate, these can get messy. (These animations by my friend poulenque.)
Among all these possible orbits, though, there exist some which repeat after some time. These are called n-body choreographies (with n = the number of bodies), small islands of order in a large chaotic space of ways-things-can-be. That’s what all those other animations are. (These animations are by Chris Moore, from here, where he has some others too.)
Most of these are completely unstable, in that the slightest nudge or imbalance in their masses will get amplified until they go flying. However, the one that traces out a figure 8 above is only somewhat unstable, in that (apparently) it will resist small nudges or variations in mass. It is estimated that between 1 and 100 naturally-occurring such figure 8 configurations exist in the entire observable universe.
In all of the animations above except for the second, the masses of all the objects are the same. This is important if you want to wonder about them.