Turning water pump on/off using Arduino Uno R3
The motor almost certainly needs more "drive" current than what the IO pin can supply. An output pin might supply (say) 40mA but the motor might need 1A or 2A. The IO pin can't provide the current so the motor sits there doing nothing.

Think of it like water pressure and feeding water through a really small pipe (say 2mm diameter). If the flow rate demand is low it'll work fine but if you want to fill your tub then forget it. Get bigger pipes - the output pin has only got little pipes.

What you need is a transistor that reacts to the lightweight IO line and switches a heavy-duty power-line to your motor. Recently i did this: -



It is a circuit that takes an IO pin from a micro and uses a couple of transistors to switch a battery (5.5V) to a load (motor). It can run from 5V of course.