While Spain was racially "pure" in the sense that the Moors, Jews, gypsies and other ethnic groups had been kicked out centuries before, the New World populations were a mixture of Europeans, Indians and blacks brought in as slaves. The highly racist colonial society was extremely sensitive to minute percentages of black or Indian blood: your status in society could be determined by how many 64ths of Spanish heritage you had. Spanish law allowed wealthy people of mixed heritage to "buy" whiteness and thus rise in a society which did not want to see their status change. This caused resentment with the privileged classes: the "dark side" of the revolutions was that they were fought, in part, to maintain a racist status quo in the colonies free of Spanish liberalism.
Napoleon Invades Spain: 1808
Tired of the waffling of Charles IV and Spain's inconsistency as an ally, Napoleon invaded in 1808 and quickly conquered not only Spain but Portugal as well. He replaced Charles IV with his own brother, Joseph Bonaparte. A Spain ruled by France was an outrage even for New World loyalists: many men and women who would have otherwise supported the royalist side now joined the insurgents. Those Spaniards who resisted Napoleon begged the colonials for help but refused to promise to reduce trade restrictions if they won.
The chaos in Spain made the perfect excuse to rebel and yet not commit treason: many said they were loyal to Spain, not Napoleon. In places like Argentina, colonies "sort of" declared independence: they claimed that they would only rule themselves until such a time as Charles IV or his son Ferdinand were put back on the Spanish throne. This half-measure was much more palatable to some who did not want to declare independence outright. Of course, there was no real going back from such a step and Argentina formally declared independence in 1816.
The independence of Latin America from Spain was a foregone conclusion as soon as the creoles began thinking of themselves as Americans and the Spaniards as something different from them. By that time, Spain was between a rock and a hard place: the creoles clamored for positions of influence in the colonial bureaucracy and for freer trade. Spain granted neither, which caused great resentment and helped lead to independence. But had they agreed to these changes, they would have created a more powerful, wealthy colonial elite with experience in administering their home regions - a road that also would have led directly to independence. Some Spanish officials must have realized this and the decision was taken to squeeze the utmost out of the colonial system before it collapsed.
Of all of the factors listed above, the most important is probably Napoleon's invasion of Spain. Not only did it provide a massive distraction and tie up Spanish troops and ships, it pushed many undecided creoles over the edge in favor of independence. By the time Spain was beginning to stabilize - Ferdinand reclaimed the throne in 1813 - colonies in Mexico, Argentina and northern South America were in revolt.
Lynch, John. Simón Bolívar: A Life. 2006: Yale University Press.
Scheina, Robert L. Latin America's Wars: The Age of the Caudillo, 1791 - 1899. 2003: Washington: Brassey's, Inc.