What causes static electricity and small shocks?
Static electricity is caused by an imbalance of electric charges on the surface of materials. When two objects rub together, electrons transfer from one surface to the other, leaving one object positively charged and the other negatively charged. Materials like wool, rubber, and certain synthetics are especially prone to this.
The small shock you feel happens when you touch a conductive object, like a metal doorknob, and the built-up charge rapidly discharges through your body to equalize the imbalance. This is more common in dry conditions because humid air allows charges to dissipate gradually, while dry air lets them accumulate. Walking across carpet in socks is a classic way to build up a significant static charge.