https://en.m.wikipedia.org/wiki/Etymology_of_ham_radio
At the turn of the 20th century, the terms "ham" and "plug" were used by landline telegraphers to describe an operator "who lacks ability"[2] or who had poor or "ham fisted" skills.
...
Even among amateur radio operators, the term was used pejoratively at first by serious experimenters. For example...
...
But many other amateurs increasingly adopted the word "ham" to describe their hobby and themselves during this period, embracing the word that was originally an insult...
(Just some quick highlights fromn the wiki. I recommend reading the whole thing.)