A detailed examination of all the possible origins of this word was published in Blackwood's Magazine in 1974. The writer, ASC Ross, favoured 'Waterloo' but could not definitively prove it. As a result, The Oxford English Dictionary, the 'bible' of word origins, says: "etymology obscure".
There are times when we just have to accept that there is no certain answer.
Certainly, the earliest recorded use of it was in James Joyce's Ulysses published in 1922. He, of course, was noted for a love of playing around with words, so maybe the whole thing is just an Irish joke!