From the 15th century onwards the South American countries were Spanish colonies. But from the 16th century on many revolutions took place, including the French revolution that put an end to the monarchy. In South America the terrible conditions of the working classes and slaves caused a number of uprisings and the English tried to invade colonies that belonged to Spain.
This all generated an awareness of the continent in regards to its own capacities and powers and several local military bodies were created. On the other hand, the Spanish monarchy itself had planned to give total independence to the American viceroyalties, but things happened and dramatic events interrupted these processes under Philip IV's reign. The fact that these countries all had the Spanish language in common is not unimportant.
The causes for the independence movements in each country are different and particular, but the French revolution and the Declaration of Independence of the United States are recognized among the influences that were common to most if not all.
But it is true that the creoles wanted to their independence from Spain and form their own nation. They wanted more political and economical power. They believed the colonial system was unfair, as they were excluded from the political decision making process.
There were also liberal ideas diffused in America thanks to the Illustration. Another important factor was that the creoles did not agree with some aspects of the Spanish Constitution of 1812, such as the land distribution, o the political equality between them and the indigenous peoples.
Some other causes were related to the waning prominence of Portugal and Spain, specially patent when Napoleon's invasion of the Iberian Peninsula and the support they received from the UK and the US, which were interest in these countries' independence from Spain, which would allow a freer flow of trade, this support translated into financing and material supply for their independence projects.
If it hadn't been for the Napoleonic occupation in Spain it might not have happened then. The the Spanish classes took up in arms which resulted in the Spanish war of independence and the creation of self-governing Juntas (an administrative form of government which comprises a board of administrators, not just one person who makes all the decisions) in the different Spanish provinces.
During the following years there were declarations all over Latin America to form American government Juntas in order to maintain king Ferdinand VII's rights, despite the fact that Napoleon had tricked him and his father into giving up the crown to set up his brother Joseph). These Juntas autonomous and maintained their independence from Spain, be it the Napoleonic empire or not.
A series of local independence movements began that disavowed the the nominations proceeding from the Spanish colonial government, and their justification was that the legitimate heirs of the Spanish crown had been forced to abdicate and the throne had been usurped by Joseph Bonaparte
In the following years, however, the conflict turned even more radical and the Juntas became a National Congress in which each state declared its independence from Spain. This process began in Paraguay in 1811 and ended in Bolivia 24 years later
Inevitably, violence followed. The revolutionaries disavowed the monarchic authorities in America, they established republics and armies. The Spanish government and the restored monarch Ferdinand VII denied the legitimacy of the American government juntas and great armies loyal to the royals were summoned, though most of the soldiers were Americans.
The main actors of the independence from Spain theatre of war were Simon Bolivar and Jose de San Martin, known as the Liberators (liberators), and the leaders of the Royalists were Pablo Morillo and Viceroy Fernando Abascal.
Despite the European country's efforts to keep their colonies like summer camps, sooner or later each country in South America gained their independence from Spain at cost of blood and and death:
Eventually these first nations would result in the current ones:
However the Caribbean, Cuba and Puerto Rico remained part of the Spanish kingdom until 1898
Many regions in South America were impoverished after the independence wars, mainly due to the disappearance of trade monopoly and protectionism. They simply couldn't compete with Europe and Bolivar's dream to create the United States of South America failed in the Panama congress in 1826.
However some are of the opinion that the independence from Spain benefited the new states because they had the chance to develop in relation to their own needs. Unfortunately there were no real social changes for the mixed races, creoles or indigenous races and slaves.
The Spanish seemed rather indifferent, they just didn't think it was their problem. For the traders and the government, an important source of income disappeared entirely, specially for the treasury. But the Spanish immersion in their own civil wars was at it's zenith, this and the loss of its American colonies made of Spain a a second order world power.