The US and UK assisted a nationalist and westernized monarch retain and consolidate power. They did not install a theocratic government. The current theocratic government came into power as a reaction against the Shah the British and US had helped.
The democratically elected president had even more western values and his only flaw was that he was a bit too socialist for the local elites, who couldn't have thrown him off without US pushing for cooperation.