There's more to the story than meets the eye. I remember reading about it some time ago. Unfortunately I don't have any of the information to hand, but due to increasing pressure from below a decision to continue the dictatorship would have been a bad idea. The best way to defuse the social tension was to transition to a parliamentary democracy, repressing any threatening popular movements in the process.
Is that the point? Politicians don´t always act in their own interests. Quite often they don´t, think of Mugabe: wouldn´t it be much better
for him to leave the country and enjoy the rest of his live spending all the money he has (without doubt) already stolen from his country?
Maybe Juan Carlos was just an opportunistic dick who wanted to avoid ending up hanging upside down from a traffic light in Madrid. Or maybe he realized there´s nothing he could do as long as Franco is alive so he played his game until he died and make a bold move
then. Who will ever know?
The point is: given the circumstances, you´d expect a politician in his situation to do exactly what Franco expected him to do: hold on to his power.
Instead, he handed it over. That was risky, too. The clergy didn´t like that, the royalists didn´t like it and the military certainly didn´t like it, too. All these people had a lot to lose, so he may have thought whatever he does, he could end up hanging upside down from a traffic light in Madrid either way.
By doing what he did, Spain was turned into a constitutional monarchy with all the power handed over to an elected parliament. A parliament with a leftist majority!
What would have been the possible consequences if he followed the road Franco paved so nicely for him? At least a catalan ETA, possibly a separation war in Catalunya, maybe even a new civil war.