Dryers and other electric household appliances are not supposed to shock their users. If your dryer is shocking you when you touch it, you have an electrical insulation breakdown somewhere within the machine plus a faulty ground connection that's made the insulation problem noticeable via the electric shock. Faulty grounding is common in homes with old wiring.
Nature of the Problem
Electricity is supposed to stay confined to a specific path through the appliance. In the case of a clothes dryer, electricity is supposed to emerge from the wall outlet via the hot or energized wire, pass through the drum motor and any electric heating element to do the work of drying your clothes, and then follow the neutral wire back to the wall outlet where the electricity returns to ground. Somewhere in your dryer is an electrical insulation fault that has allowed electricity to escape from the proper path and stray to the outer metal shell.
If your dryer is grounded, that stray electricity has a path to ground and you won't feel anything. However, your dryer must not be properly grounded because stray electricity is finding its path to ground by passing through you when you touch the machine. This condition is dangerous. A little tingle of shock now can later without warning turn into a jolt powerful enough to injure or even kill you. Unplug the dryer and don't use it again until you find out the cause.
Your dryer should be equipped with a 3-prong grounded plug that fits into a matching grounded outlet. If it has a serious electrical fault, the grounding prong is supposed to carry the stray electricity directly to the neutral wire, creating a short circuit that trips the circuit breaker to cut off power to the machine. If the plug's grounding prong is missing or if no one connected the outlet's grounding plug to the house wiring, the stray electricity won't have a path to ground until you touch the machine and provide a path.
Ground Fault Interruption
The National Electrical Code requires that electrical outlets in basements, kitchens, laundry rooms, garages and kitchens be equipped with a ground fault circuit interrupter or GFCI. These devices monitor the current flow in the hot and neutral wires. The current should always be the same in each wire. If there's a difference between them, that means electricity has escaped and found a path to ground other than the neutral wire, creating a dangerous condition. The GFCI responds by instantly cutting off power to prevent a deadly shock or electrical fire. GFCI-equipped outlets have two buttons, one for testing and the other to reset the device.