I do not believe the goal of the CIA was to establish the Islamic republic. I remember that period, approximately 1979-1980, and I had school friends from Persia who worked with the Shah.
I agree that many times what the CIA does ends up back-firing, as in the case of Al-Queda whom they supported in the war in Afghanistan against USSR. Also the dealings with the Panamanian dictator, and others...