I get that it's probably related to league, but where does the concept come from?
It's from the Latin noun legio, legionis, itself a derivative of the verb lego, legere 'choose, collect'. The word league is actually from ligo, ligare 'tie, bind'. The two words descend from different PIE roots, the first from *leǵ- 'bind' and the second from *leyǵ- 'gather'.