One of the most fundamental applications of a transistor is using it to control the flow of power to another part of the circuit -- using it as an electric switch. The transistor can create the binary on/off effect of a switch.
A small transistor like the PN2222 can be used as a switch that uses just a little current from the Arduino digital output to control the much bigger current of a motor.
The transistor has three leads. Most of the electricity flows from the Collector to the Emitter, but this will only happen if a small amount is flowing into the Base connection. This small current is supplied by the Arduino digital output. (Adapted from Sparkfun and Adafruit)