Napoleon certainly inadvertently did those Spanish colonies a favor-my ancestors had intermarried with Natives/Indians and left Mexico for Texas and NM-the frontier-by 1790-as reputed Basque rebels, the further they were from the Spanish government the better they liked it...
Even earlier, the original colonies were a refuge for Jews from the Inquisition; some left Spain for the New World rather than accept forced conversion.
Brazil was an odd situation where the people there wanted a Portuguese prince for their king; I don’t think that arrangement lasted long (and it was decades after the Spanish colonies were independent).