Mostly because a lot of people don't think the consequences through fully. In making rules, people usually are reacting quickly to a situation at hand, coming up with what usually amounts to no more than a bandaid solution (and one that, if I might continue the metaphor, fails too often to cover any wound at all). Sometimes it's just good intentions gone awry due to shortsightedness or lack of information, while other times a rule might be bad because of outright intellectual laziness, scapegoating or other corrupt motives.
From there, people are hired or appointed to enforce this rule. The sort of people, usually, who like enforcing the more minor rules in life (the ones that least directly affect people's actual well being) are people who will go completely nuts with even the tiniest shred of power that makes them feel that much more important for having. Even if the rule itself wasn't inherently bad or flawed, you can count on some of its enforcers to make the solution worse than the problem, usually by being so anal about it that they miss the big picture or by being unnecessarily harsh on any offenders.
Then there are just some rules that were good for their specific time period, but are now outdated, inconvenient and downright unfair, but either have sentimental value to people of some sort to the point that most have forgotten their original purpose or everyone's just too lazy to get rid of them.