Humankind has a need to explain things that happen, particularly things that go wrong (bad luck) and as patterns arise the people ascribe significance to them.
Superstitions come about when those happenings get passed from one small group (ie. a family) to a larger group (the town they live in and eventually the whole area).
Some of them have a strong basis in fact or just common sense - bad luck to walk under a ladder... there could be someone working above and something may fall on you.
Others come from simple cause and effect - like the athlete that won't wash his socks while he is on a winning streak.