More technically, there are several gears in the base of the fan that cause the fan blades to turn and then return; in most fans there are three gears, but sometimes more.
The theory is that consistent fan usage (stationary) will become annoying, while the oscillation provides variety/diversity in what the person feels on their skin.
The science is the same for oscillation or stationary fans: The way a fan keeps you cool is that it either blows cold air across your skin so you lose heat via a process called convection and it helps sweat evaporate faster.
Fans do not cool the air. They move the air causing a human perception of coolness.