The war was fought to decide whether a Bourbon or a Habsburg would sit on the Spanish throne.
The major issue among Europeans nations between the middle of the 17th and the beginning of the 19the century was the balance of their power. France, Spain, England and the Austrian Empire, each with its cohort of clients and allies, represented more than 80% of the world trade. This quantity was unevenly distributed, but
clearly geographically divided. Spain controlled the huge slave and bullion trade to South America and the Far East; Austria dominated Central Europe and the old hanseatic Baltic commerce; France and England shared North America and most of the Caribbean.
The Low Countries held some sort of deciding power since part of it was administered by Spain, part by the Habsburg and the independent section was essentially allied to England when they were not at war with them.
Any modification to this equilibrium meant great losses for the one power and huge profit for the others. It is not surprising therefore that they all kept a close eye on whatever move the neighbour might be planning and did their utmost to prevent it.
Charles II of Spain had died heirless. He had named a nephew of Louis XIV as his successor but none of the other powers was prepared to accept such decision.
Uniting France with Spain plus their oversea colonial domains under the same crown would alter the balance and greatly menace the economy of the other powers. On the other hand, uniting Spain to Austria was equivalent to bringing back to life the old Empire
of Charles V spanning the whole world. Which was also inacceptable.
The Spanish Succession War was fought to determine who was to sit on the Spanish throne after Charles II. But there was a lot more at stake than a crown to fight for.