What looks like magic is actually a super simple physics experiment in this viral video from the Ikeguchi Laboratory in Japan. Joe Hanson, a scientist and creator of the excellent It's Ok to Be Smart tumblr, explains that the key is a rolling platform:
When the arm of any metronome hits the side, it exerts a force on the blue platform. Normally friction would make that unnoticeable. But this platform is special. It's set up on rollers so that it can move from side to side. When any two metronome arms hit, their forces on the platform either cancel out or add together, depending on how out of or in sync they are. Any arms that are out of sync will experience a force in the opposite direction that inches them closer to the pack.
The phenomenon is easier to follow in another video from the lab, featuring just two metronomes on a suspended platform:
For more videos from the Ikeguchi Laboratory, visit the YouTube channel.