I always thought that it stemmed from the Napoleonic wars when Napoleon put a relative on the Spanish throne thus deposing the rightful Spanish King of the time. There were a number of Irish regiments fighting with the English at this time so I reckon it is possibly true.