In one lineStatic electricity is electricity that builds up on the surface of an object and doesn't move. It forms when electrons move, for example when two different things are rubbed together.
Static electricity is electricity that builds up on the surface of things and stays put. It often comes from rubbing two things together. When they rub, electrons move from one to the other. One side ends up plus, and the other ends up minus. When that built-up charge jumps from your fingertip to metal all at once, zap! It stings. That's why it happens more in winter, when the air is dry. The voltage can reach thousands of volts. But so little electricity flows that it does no real harm. Lightning is giant static electricity made inside clouds. The doorknob is just a smaller, pettier version.
Common mix-upIt doesn't only happen in winter. In damp seasons the charge escapes into the air more easily, so you just notice it less.