"Ham: a poor operator. A 'plug.'"
That's the definition of the word given in G. M. Dodge's The Telegraph Instructor even before radio. The definition has never changed in wire telegraphy. The first wireless operators were landline telegraphers who left their offices to go to sea or to man the coastal stations. They brought with them their language and much of the tradition of their older profession.
In those early days, spark was king and every station occupied the same wavelength-or, more accurately perhaps, every station occupied the whole spectrum with its broad spark signal. Government stations, ships, coastal stations and the increasingly numerous amateur operators all competed for time and signal supremacy in each other's receivers. Many of the amateur stations were very powerful. Two amateurs, working each other across town, could effectively jam all the other operations in the area. When this happened, frustrated commercial operators would call the ship whose weaker signals had been blotted out by amateurs and say "SRI OM THOSE #&$!@ HAMS ARE JAMMING YOU."
Amateurs, possibly unfamiliar with the real meaning of the term, picked it up and applied it to themselves in true "Yankee Doodle" fashion and wore it with pride. As the years advanced, the original meaning has completely disappeared.