This curious etymological fact popped up on HH today:
It’s a curious one, alright. And it’s not a particularly explainable one either.
What we do know is that English picked up the word pedant sometime in the mid sixteenth century, either from French or Italian, and began using it (as the French and Italians did) to mean “schoolteacher” or “instructor”. In the sense of someone who peddles knowledge, it was only a hop, step and a jump from there to “someone who shows off their knowledge” (first used in the 1590s), and ultimately “a trifling nitpicker” (which had established itself as the dominant meaning by the 1700s).
As for where the word came from in the first place, we’re at something of a dead end. It’s possible that its roots lie in the same place as pedagogue: a paidagogos back in Ancient Greece (or a paedagogus in the Latin of Ancient Rome) was originally a slave whose job it was to escort children to school. It’s possible some kind of confusion with pedante, an old Italian word for a foot soldier, came in to play somewhere along the line too, but all told there is still something of a question mark hanging over this one. The pedants would hate it.