The story behind this saying that doesn't seem to make sense.
An exception to a rule is a counterexample, and usually a counterexample is proof that a rule is not a rule at all. If I aim to prove that teenagers are incapable by nature of cleaning their rooms and I find one who loves to clean his room and does it diligently every day, my case is not helped at all but damaged. The exception is evidence against my rule.
Still, it wouldn't be unusual to say about such a teenager "He's the exception that proves the rule!"
When the phrase is used this way, it's a form of saying "Look, here's something noteworthy!" It says that there's a general rule: that teenagers don't clean their rooms—and an exception that doesn't fit: the kid who loves to clean his room. But it doesn't say anything about one proving the other. How did this idiom come to be?
"The exception that proves the rule" is based on the Latin phrase "exceptio probat regulam," a legal principle that can be used to argue the following: if exceptions are made under specific conditions, it must mean there is a rule that applies when those conditions are not in effect. If a sign on a concrete plaza at a school says the following:
"No Skateboarding When School Is in Session," you can infer that you are allowed to skateboard at other times. The rule that the exception proves is that skateboarding is generally allowed. If that were not a rule, why would exceptions be made at all? Why not just say "No Skateboarding"?
The fuller version of the Latin maxim is "exceptio probat regulam in casibus non exceptis." This make the meaning more explicit: exception proves the rule in cases where the exception doesn't apply. It can also appear with "firmat" "confirmat" and "figit" instead of "probat" (exception establishes, confirms, and fixes the rule).
When the phrase drifted from its original, legalistic meaning sometime in the seventeenth century, it was probably helped along by its similarity to sayings like "There's an exception to every rule." It was also influenced by a different sense of "rule," not the legal sense of a standard or what is allowed or prohibited but a looser sense, meaning the normal or usual state of things.
This is the sense we use when we say things like "As a rule, I bring my lunch from home." This isn't a declaration that I have a strict policy about never buying lunch at work. It's just saying what I ordinarily do. Something that happens "as a rule" is assumed to have occasional exceptions.
So "as a rule" teenagers don't clean their rooms. It's the usual state of affairs, the generalization, the stereotype. The kid who loves to clean his room is unusual, an outlier. But to be an outlier, he has to be an outlier to something. A general tendency, a rule. He proves the rule by being surprising.
This may not be what people have in mind every time they use the phrase, but there is a pathway in the language over time from legal maxim to comment about usual state of affairs. It involves different ideas of what is a rule, a principle, an axiom, a regulation, versus the typical, the expected, the norm. There was a ready-made phrase, already in use for the first sense, that we co-opted for the second sense.