Here's some previous threads answering very similar questions:
Edit: A little bird told me I should ping the authors of answers I referenced: u/AlotOfReading, u/davidAOP u/Legendarytubahero, u/masiakasaurus, u/counterc, u/Shalaiyn
Obviously this is a vast questions, and there are numerous different factors which would help to explain why Spain lost each of its colonies. However, seen as at the question refers to a rather grand trajectory spanning several centuries, I think there are two very broad explanations for this apparent decline which focus respectively on the history and politics of early modern / modern Europe and of colonial Latin America.
Firstly, when you say about "one third of Europe", I assume the question is referring to the territories to Charles V incorporating the Holy Roman Empire, Spain and the Netherlands. These territories were associated with Spain in a very different way to the Latin American colonies because they were gained by inheritance, not by conquest. Because of this, Charles V was leader of both Spain and large areas of Europe, but I think you would be hard pressed to argue that they formed a formal part of the Spanish Empire as colonies. Charles V was involved in near continuous wars with a number of enemies who were worried about the large amount of power and wealth he had amassed, and by those who supported the Protestant Reformation. Wars with the Netherlands, France and England were very costly to Spain who faced bankruptcy on a number of occasions, but the Spanish Habsburgs (descendants of Charles V) retained power until the last Habsburg died in 1700. This led to the War of Spanish Succession (1702-1715) in which various European rulers and nations supported different successors to the crown. As a result of the war, Philip V was recognised as King of Spain but ceded the Spanish Netherlands, the Kingdom of Naples, the Duchy of Milan, Sardinia, the Kingdom of Sicily, Gibraltar and Minorca to other European powers.
It's difficult to explain this decline of Spanish power in Europe with a simple, one line explanation, but as you can probably tell it was a very long process involving most European powers in conflict. I think it would be fair to say that this continuous war did weaken the Spanish Empire, and that the ascendancy of England and the Netherlands (Protestant, naval powers) brought them into direct conflict with Spain. Most of all, however, Spanish power in this period was tied to the Habsburg family and its inheritances, and as such was always to some extent more unstable than in formal colonies.
In the Spanish Americas, the reasons for Spanish decline are somewhat different. Doubtlessly, the European wars restricted the ability of the Habsburgs to maintain tight control of the American colonies, not least because of bankruptcy. However, I think John Lynch puts forward a fairly convincing argument that rather having a clear and direct affect, Spain's European troubles in the 17th century created a loosening of direct control in the colonial political structures in the Americas which increasingly allowed Creole Americans to participate in government, and which allowed a greater degree of negotiation and bargaining between colonial powers and the American population. Lynch continues to argue that when the Spanish Bourbon monarchy came to power in the eighteenth century and instituted reforms which were deeply unpopular in Spanish America, as they re-formalised Spanish power and deprived Creoles of political participation. Lynch suggests that when Spain was invaded by Napoleon in 1808, the Bourbon reforms had caused sufficient frustration in Spanish America that Creoles took the opportunity of freeing themselves from colonial rule (as the Cadiz Cortes acted as the Spanish government in exile).
Of course, not everyone who lived in Spanish America was frustrated with colonial rule (see the Echeverri article below) and there was a great deal of resistance to the Wars of Independence. In this sense, the role of the Liberators Simón Bolívar and José de San Martín in achieving military victories against colonial rule were highly significant for managing this transition from colony to independence. Yet, in may ways they also took advantage of the opportunities presented by the European wars and Bourbon reforms.
So, if I were to try and reduce that argument to one idea, it would be that the Spanish Empire at its peak was very much built upon, and rooted in, institutions which held a huge amount of wealth and political power in the 16th century: the Habsburg dynasty, the Catholic Church and the colonial administration in the Americas. In many ways, it was the challenges and weakening which each of these faced in the following 2-3 centuries which fundamentally undermined the Spanish Empire as a whole.
Berenger, Jean. A History of the Habsburg Empire 1273-1700 (Routledge, 2014).
Echeverri, Marcela. 'Popular Royalists, Empire, and Politics in Southwestern New Granada, 1809–1819', Hispanic American Historical Review 91:2 (2011).
Hamnett, Brian R. 'Process and Pattern: A Re-Examination of the Ibero-American Independence Movements, 1808-1826', Journal of Latin American Studies, Vol. 29, No. 2 (May, 1997), pp. 279-328.
Lynch, John. 'The Institutional Framework of Colonial Spanish America', Journal of Latin American Studies, Vol. 24, Quincentenary Supplement: The Colonial and Post Colonial Experience. Five Centuries of Spanish and Portuguese America (1992), pp.69-81.
As some will point out, there are various reasons, here's a couple of reasons we discussed in two classes I took as an undergraduate that deal with this. Of course there's war, but plenty of people will cover that one. One cause we discussed was economic. The vast amounts of gold coming from the new world created rampant inflation in Spain. Coupled with the fact they could now afford anything they wanted and needed, there was no need to manufacture domestically. This lead to Spain lagging behind other countries when it came to technological advances. A good source to get more in depth information is "The Rise and Fall of the Spanish Empire" by William S. Maltby
Just to add some clarification to your question Spanish territories in the American continent not only included Central and South America but North America too. Mexico and significant parts of today US. As a matter of fact the New Spain territory plunged deep into the center of the US and into what is now Canada. It was just barely populated. Not being picky but just to illustrate how vast the Empire was.