If the PoD has to happen no before than the Napoleonic wars, all i can think of is:
Napoleon, who already had a good part of the royal family as prisioners, advices his brother Joseph to seize up the rest. As the Spanish Independence War progresses, Napoleon and his brother realize that keeping them as hostages isn't helping at all to keep the Spaniards from revolting, even worse, it's giving them hope to overthrow the French (Fernando VII was nicknamed "the wished for one" at the time). So it's decided, that the whole royal family will be executed, and so it's done, shortly after.
With this PoD (dunno how much of ASB it is...), you can ensure that there will be no Carlist civil wars, at the very least (a huge drain of resources and population). You can also have Cadiz Constitution to last a lot longer, maybe even enough to transform Spain into an actual constitutional monarchy.
A King would have to be brought from outside, there would have to be an election, kinda like it was needed much later on in OTL. Even if a republic (monarchy with vacant throne, actually) could be stablished at first, chosing an actual king would be necessary to avoid the intervention of the 100,000 children of St. Louis. Depending on who you chose to become king of Spain (to make it realistic, the Court would chose someone who was trusted to believe in the values of the Constitution), you can have a much different XIX century for Spain.
In fact, without Riego's Pronunciamiento, a large chunk of the American territories could be kept. Not only manu militari: 1812 Constitution acknowledged all the inhabitants of Spanish America were Spaniards all the same, and with the same rights, as those who lived in the peninsule. This certainly would satisfy many of the liberals who were behind the american independences.
Additionally, a liberal constitutional monarchy would be politically very close to Britain, which added to the militar collaboration fighting against Napoleon, might make both countries close allies. If the Spaniards began to look up to Britain instead of to France, they could take lessons on how they used the resources from their colonies to bolster the industry of the metropolis. Doing this, the population of the British islands tripled during the XIX century. Could the same happen in Spain?
Edit: regarding the American independences, i don't think the success of the revolt could be avoided in Mexico, Argentina, Chile and the Great Colombia. So Spain might get to hold Perú, Bolivia, Central America and the Caribbean islands. Maybe chunks of Mexico here and there. I don't know how hard the US pushed to obtain Florida from Spain in OTL, so Spain keeping that too is a posibility to explore.