It is not quite correct that, as some answers here suggest, this is "the" archaic sense of the word learn.
Nor though, is it quite wrong either.
It is an archaic sense, that is still found in some dialects.
In the sense of acquiring knowledge, we have learn going back as far as Bede and other Old English writers.
In the sense of imparting knowledge, we have learn going back not quite so far, but still as far back as Wycliffe's Bible and other Middle English writers.
That it is today labelled "vulgar" in some dictionaries means that it remains current in some dialects, but is not generally considered standard or the language an educated person would use. Still, a book considered definitive enough on the Scouse dialect to have been used in the old IANA language registration has the wonderful title, Lern Yourself Scouse.
The classic example is 'that will learn them!', as in "Shoot all criminals - that will learn them!". I thought this was being deliberately wrong for comedic effect, in keeping with the general sentiment of the sentence.
It depends on the speaker. Some people whose dialect would not have them normally use learn in this sense will still use the expression "that'll learn you" and variants ("that'll learn them" and other objects that it will "learn"). It does indeed use a degree of humour, though it's not so much that it is incorrect (and hence at odds with the statement) as just a common enough expression among those whose dialect does allow for that use, as to have become an idiom. In particular, some dialects would allow this sense of learn only informally, and therefore to use such an informal expression when this sense of the word doesn't otherwise exist in your dialect at all is actively informal. The humour isn't in "being wrong" it's in taking pains to be informal.
Of course, one can still make use of it as humorously uneducated too. When Wodehouse has an upper-class character say of the English public school system, "If you ask me, they don't learn the little perishers nothing." then it is precisely this sort of humour.
When however, Twain writes "Then he remarked that he had undertaken to 'learn' me all about a steamboat, and had done it;" he is distancing his narrator from the use with quotes, but reporting on a realistic use, rather than poking fun.