One skill every cyclist should have, besides changing a flat tire, is how to fix a slipped or dropped chain. A bicycle chain usually drops off a gear or chainring because the teeth have become worn and narrow, the chain has stretched or it has a bad link. You can take a number of approaches of increasing complexity to fix a dropped chain.
Pedal slowly and move the front derailleur up as if you are going up to the larger chainring. This is done with the left gear shifter, which is typically located on the left handlebar. You don't have to move the derailleur as if you're moving the chain all the way to the larger ring, only enough to cause the chain to slip back onto the smaller ring. Pedal slowly a few turns to ensure the chain is set. You can now continue your ride.
Stop pedaling, coast to a stop and get off your bicycle if you were not successful with the instructions in Step 1. Use the left gear shifter and move the front derailleur up toward the larger chainring. Lift the back wheel off the ground with one hand and slowly turn the crank or pedals with your free hand until the chain pulls back up on the chainring. Once the chain is set, you can resume your ride.
Fix the chain manually if the previous methods didn't work. Coast to a complete stop, get off your bicycle and press the rear derailleur forward to release some tension from the chain. You can use a twig, tissue or a plastic bag, if available, to keep your hand clean. The rear derailleur hangs below the rear cassette or cluster of rear sprockets. With your other hand, or a second twig, bag or tissue, lift the chain and place it on top the small chainring. Release the rear derailleur, lift the back wheel off the ground and manually turn the pedals until the chain is set.
If the chain continues to slip off the gears, have a bicycle mechanic inspect the chain and drive train for wear. Often the chain and rear cassettes need to be replaced together. A poorly maintained bicycle chain could break while riding, which may lead to an injury.