Shifting is used to maintain leg speed so you are more efficient when riding on different terrain (up hill, down hill, flat, windy, etc). You can use certain cycling computers to measure your leg speed which is also known as cadence.
To break it down, larger gears on the rear wheels make your leg speed faster. Larger gears on the pedal side make you leg faster if your bike has front gears.