The Latin American Wars of Independence were precipitated by racism and the class system, Napoleon's 1808 invasion of Spain and the impending political chaos this created. People from the privileged aristocracy in particular sought political self-governance in the early 19th century.
Political, economic and social rights in Latin America were determined by a racially organized system of "purity" of blood that privileged whiteness (Spanish heritage). Spanish law allowed for people of so-called "mixed" heritage to buy their social privilege, which caused resentment among the wealthy and intra-colonial turmoil among local populations.
Napoleon's 1808 invasion of Spain, in which he replaced the Spanish monarch with his own brother, precipitated much of the Latin American wars of independence. Loyalists who would have sided with Spain under a Spanish monarch joined the insurgents.