Franklin touched his knuckle to the key and was shocked slightly by the electrical current. This supported his hypothesis and he went on to construct the lightning rod to protect buildings and houses from lightning strokes. He was lucky because the shock he received was mild; had it been stronger Benjamin Franklin could have been seriously injured or killed.
Your feet are obtaining electrons from the carpet. This is similar to the positive charge the ground takes on as large clouds pass overhead (see From cloud to Earth).
If you touch something metal or another person, they conduct the electrons that you have gained from the carpet. This is because the charges are different between you and the object you touch. Ultimately, a shock is caused from the circuit being completed and the energy transfers from you to the object in an effort to equalize the charge differences.
The clouds passing over the ground, as mentioned above, are charging Earth's surface. As this happens, the air around us is being altered as the charges change. For this reason, people can feel the hairs on their neck stand on end at times. Because our bodies are charged differently than the air around us, but not to a strong enough degree, the hairs will stand on end, but we do not get random shocks.
Another example would be a television set. If you put your arm next to the screen, your arm hairs will stand up toward
the screen. This is because of the energy and electricity involved when the television is in use. Sometimes, when you touch the screen
you may get a small shock. This is to equalize charges and maintain balance.