Doing this helps the chain move quickly and smoothly to the next larger cog (rear shift) or smaller chainring (front shift).
Modern drivetrains do a great job of shifting under load, but you can give them a hand with this technique. Simply reduce pedaling force on the stroke during which the shift takes place, then immediately pour on the coals again.
This is especially helpful for a front shift. If you're caught in the big chainring on a climb and begin bogging down, there's a huge load on the chain. It may be so tight that the derailleur can't pull it over to the small ring to give you a lower gear.
Coordinate your left hand with your legs. As you move the gear lever, soft pedal for one stroke. Keep the crank turning but with much less force. The chain will drop cleanly down. Then resume mashing.
Ideally, you'll anticipate shifts and make them before putting the chain under a heavy load. But when you goof, this technique will bail you out.