Many different factors, including the decentralized political nature of Spain, inefficient taxation, a succession of weak kings, power struggles in the Spanish court and a tendency to focus on the American colonies instead of Spain's domestic economy, all contributed to the decline of the Habsburg rule of Spain.
(website is Wikipedia the name of the article is Spain in the 17th century)