
At one time the Habsburgs were famous for making advantageous marriages to heiresses (and then inheriting that territory). Somewhere along the way the Spanish Habsburgs forgot that and the result was a disaster in the case of Carlos II. But an earlier member of the family had married into the French royal family which led to Louis XIV being able to get his grandson accepted as King of Spain (the beginning of the Borbon line).
Say what you will about the Habsburg lip it beat the inconvenience of always having to carry paper proof of royal parentage on one’s person.