The verb learn has long been used to mean "teach" (the usage goes back to at least 1200), and though now it's regarded as an error and generally confined to certain dialects, it has a legitimate etymological reason for existence.
In Old English they were two verbs, and they started to collapse together in Middle English. On the one hand there was leornian, which had the "learn" meaning. Then there was the related word læran, which had the "teach" meaning. They're also related to the word lore, which means "the act of teaching" or "that which is taught."
But leornian and læran didn't exactly collapse together. When word endings started disappearing in Middle English, the usual course of action was to drop the -an/-ian on verbs, which created the forms learn ("learn") and lere ("teach"). The word lere survived until the 1600s or so, but it's obsolete now. But as those suffixes were decaying and withering away, there was probably some confusion, and people started using learn to mean lere.
This error caught on and became standard English for hundreds of years until it started to fall out of favor in the late 1700s and eventually became branded as an error.