The taliban came to power by stopping socialist massacres, most famously in a "torture prison" the socialists built. That is what made people choose their side. They killed less people in open warfare than socialist revolutionaries did in peacetime, and much less than the Soviets did when "helping the socialist revolution spread".
Despite what happened since, sadly, I think you'll agree things never got as bad in Afghanistan as they did during the socialist revolution they had there. Not even now.
What does it have to do with the CIA coup installing the shah? Easy:
1) what happened in Iran? Socialist revolution, allied with a religious party ... followed by the religious side attacking their leftist "allies" when the state was toppled.
2) I find it hard to believe that Khomeini ordering his troops, after a referendum, to start executing leftists, and blinding yet more leftists (gouging one or two eyes out, which they have Hezbollah do again in last year's "woman, life, freedom" protests). It's a lot tougher to disagree with this strategy knowing that in the next country over leftists killed, tortured and maimed the clergy.
Like in most socialist revolutions (like in the red vs white terror in the Soviet Union), you were better off as one of the soldiers killing revolutionaries than you were as a "victorious" revolutionary. The reason leftists, at least the leaders, did a revolution turned out, surprise!, not to be social justice but power for themselves, and so they're far more scared of their allies than the police and army forces they need to keep control of what they've won.
Leftists brought the ayatollahs to power. Yes, this was partly in reaction to a British/US ("CIA") coup 20 years earlier, but ...
And I get it. Leftists have no allies willing to destroy western (or even non-Western) states for them anymore. So now they ally with islamists, who also want to destroy western states. What happened in Iran is a very in-your-face example of what would happen if a socialist-islamist alliance actually achieves anything: immediate terror attacks on leftists, followed by constant repression. And, to make matters worse, the Iranian population is screaming about this, regularly drawing attention to the problem. Which is a huge problem to grow leftist parties, because leftists don't have any other allies.
And yes, I'm not very leftist, but I must say, it is absolutely baffling to me that leftists would ally with conservative muslims, even if the Iran example did not exist.
Well not intentionally engineered by the CIA, but definitely the result of their engineering. Much like the rise to power of our brave allies the Afghani mujahideen, and many others…
And people acting in good faith don't keep beating a dead horse and don't beat around the bush to distract from the main argument I made which was that the UK & US powers meddled to overthrow Iran's democratic government to get access to Iran's oil reserves at rates favorable to the US & UK oil companies but unfavorable to Iran's government and Iran's people.
Would you be okay if other countries messed with your government to cheat you out of your tax revenue?
The revolution was a quarter of a century after the Shah came to power. It is a bit silly to state counterfactuals over such a long period in such an unstable and violent region. The Shah's reign was pretty popular during the first decade, it went quickly downhill after that. Mossadegh was only prime minister for 2 years. Two extrapolate in any way from this is ridiculous.
The US and UK were actually quite happy with the Shah they installed, he allowed western access to Iran's oil.
Edit: the post I'm replying to has been heavily edited.