THERE IS a natural temptation, in looking back Mohammad Reza Pahlavi, the former shah of Iran who died yesterday in Cario, to judge him in the light of embarrassment that he became as his reign collapsed. But the former shah cannot be judged simply by the endgame. For 38 years, this son of an illiterate mule driver ruled Iran, seeing it-- leading it, whipping -- through a crude incomplete and flawed but stunnngly ambitious transition from a feudal to a "modern" state. The verydeeds for which Ayatollah Khomeini hated him, such as distributing land (much of it church-owned) to peasants, enfranchising women and undertaking moderization, were for years hailed by many outside Iran as enlightened achievements -- as they were. Only later did a perception dawn that in their assault on the traditional culture and on the very equilibrium of the country, the reforms had a dark underside.

For most of the former shah's reign, nations outside the region found him a friend. The soviets, and british, expelled his father as a pro-German sympathizer in 1941 and made Mohammad Reza shah atage 21. The Americans restored him to power in 1954 after a nationalist prime minister had forced him into his first exile. The Americans again, scarcely realizing they were confirming his enemies' claim that he was the pet of foreigners, promoted him into the role of Persian Gulf policeman when Britain quit "east of Suez" in 1970.

The unraveling began to speed up then. In 1971, the shah presided over a self-aggrandizing and ultimately self-defeating celebration of 2,500 years of Iranian monarchy. In 1973, the tripling of world oil prices gave him the financial means to indulge his wildest imperial fantasies. The United States, eager in the wake of Vietnam to find regioanl surrogates, lavished arms upon him and averted its gaze from the tensions that his headlong industrialization and his heavy-handed police were fanning into revolution. Jimmy Carter did not catch on until itwas too late.

With an evident eye on the hostages, the Carter administration confined itself yesterday to an expression of condolences to the dead man's family.This may be no time, officially, for a fuller evaluation. For all of the former shah's flaws of character and policy, however, his contributions to his country were real. Can anyone look at the chaos and cruelty that characterize the regime of his sucessors and think that they are doing better?