Mean has…wow, a lot of really different definitions. Like it can mean average, or intention, or someone who’s acting like a jerk. Which one should we look at first?
The one that means intention doesn’t have a real show up date, so it might be the oldest or it might not be. It comes from the Old English maenan, which could mean say or relate (makes sense!) or mourn or lament (this one, not so much). Before that it was the West Germanic mainijan and the Proto Indo European meino-, intent. And it’s not related to the other means at all because why would it. That would make sense.
The mean with the earliest known date showed up in the thirteenth century and actually meant low quality, although before that it meant shared by all. I guess something shared by all is low quality? Originally it was imene, coming from the Old English gemaene, in common or united. It’s from the Proto Germanic ga-mainiz, possessed jointly. And if you thought it was weird that there was a g at the beginning, well in Proto Indo European it was ko-moin-i-, held in common, a word related to the word mei-, change or move. Anyway, that whole low quality thing gave us a mean that meant inferior or second rate, which changed to mediocre, then inferior, then nasty, then “disobliging or pettily offensive”. And that’s why we have mean.
The average mean first showed up as a noun in the early fourteenth century, and then as an adjective in the mid fourteenth century, and as a math term in the late fourteenth century. These words are French in origin, coming from the Anglo French meines and Old French meien. That in turn comes from the Late Latin medianus and classical Latin medius, center. And yeah, that’s the origin of medium. It also comes from the Proto Indo European medhyo-, middle, the origin of a ton of words, including middle. Unsurprisingly.
TL;DR: Three means, three totally separate origins.
Tony Jebson’s page on the Origins of Old English