But why does it work? Well, it's due to a thing called the motion aftereffect illusion.
What happens is that the nerve cells that signal motion in a single direction begin to get tired after several seconds. According to the IllusionWorks website:
Your brain represents a sensory quality, such as motion, brightness, color, or depth, not in terms of the firing of one group of neurons, but in terms of the electrical activity of one group of neurons relative to the electrical activity of another group of neurons. For example, the activity of neurons coding for clockwise motion relative to the activity of those coding for counterclockwise motion.
Clockwise motion is signaled by the fact that the neurons coding for clockwise movement fire more strongly than neurons coding for counterclockwise motion. If the clockwise neurons now fire less strongly because their electrochemical batteries run down after several seconds or more of continuous activity, the balance between these two groups is disrupted.