Isn't that an Americanism, i.e. optional?
I've read originally, in handwriting, the punctuation used to come below the quotation mark, both forming what nowadays would be considered a single character. When people transitioned to print, there was no easy way to do that, so some began placing the punctuation before the quotation mark, others began placing the quotation mark before the punctuation, and over time either style became the standard in print. Most countries went for quotation-then-punctuation. The USA went for punctuation-then-quotation. And that's it. There's no right or wrong option there, just an arbitrary usage that eventually became normative.
By the way, if we were to do it "right", as in, to become historically accurate, we should ask the Unicode Consortium to provide us ligature version of the different end-quotation marks with the different punctuations available, then have word processors replace them when typed, as they sometimes do when you type three dots and those get replaced by the single ellipsis symbol. Maybe those already exist? After all, there's no technological reason for keeping them separate anymore.