It has been said repeatedly that if the United Nations did not exist, it would have to be invented. Otherwise, where would the world have turned in recent weeks as one international crisis followed another?

Although it is the fashion (especially in the United States) to denigrate the United Nations as a sterile, do-nothing, ineffectual institution, violent events have shown that when really serious trouble breaks out, threatening peace and security, the members nations rush to the United Nations with the problem.

Afghanistan and Iran are simply the latest examples of how, in a pinch, the world depends on the pacifying capacity of the United Nations to cope with inflammatory situations that might well lead to major war if military confrontation were the only alternative.

Obviously, the United Nations still can't be relied on to prevent aggression, but it nevertheless has an impressive record of sponsoring cease-fires, armistices and other helpful cooling-off devices that have often led to the restoration of peace, or something resembling it. Moreover, while its resolutions frequently produce no immediate results, they do have an impact not to be despised.

Russia will doubtless find ways of circumventing or minimizing President Carter's efforts to shut off Soviet-bound grain, but the U.N. General Assembly's sweeping disapproval of Russia's aggression in Afghanistan is not so easily laughed off.

It is Moscow's worst U.N. setback since it was censured about 25 years ago for its crackdown on Hungary. The Russians were severely stung in general by the size (104 to 18) of the hostile assembly vote on Afghanistan and in painful particular by the critical reaction of the Third World bloc. That could have lasting consequences, as the Kremlin well knows.

It is not unusual for nations to affect a disdain for the United Nations when they find themselves at odds with the institution, yet in practice they are by no means indifferent to their standing in this world body.

Unlike the League of Nations, which suffered numerous withdrawals, there have been no resignations from the United Nations in its 35-year history. Quite the contrary. Every new nation instantly seeks U.N. membership, and those that have been excluded never cease campaigning for admission.

Mainland China, for example, spent over two decades fighting for admission.

Today, it proudly occupies one of the five permanent seats on the U.N. Security Council, basking in the prestige that goes with that privileged position. The revulsion to the invasion of Afghanistan, incidentally, killed Russia's hope for electing its Third World favorite, Cuba, to the Security Council.

Depreciation of the United Nations has generally been accompanied by the belittling of the secretary general, but all the occupants of this thankless post have enjoyed growing prestige once they have acquired the confidence to act on their own. The incumbent, Kurt Waldheim, is no exception.

The United States can thank him for the Security Council action against Iran's seizure of the hostages. Originally, the Carter administration short-sightedly resisted a council hearing, chiefly because Iran was naive enough to propose it in the first place. The administration changed its mind when, after a little tutoring by Waldheim, it finally perceived that the council could address itself primarily to the hostage issue rather than to grievances concerning the shah and the United States, as proposed by Iran.

That's the way it turned out. First, the Security Council unanimously set a deadline for the release of the hostages. When that was ignored, it then passed (10 to 2) a second resolution calling for sanctions against Iran. While it was vetoed by Russia, Iran is still left acutely isolated.

The scope and explicitness of the General Assembly resolution on Afghanistan may, in the long run, have more significance than the members realized when they voted for it by such a large majority. The resolution "reaffirms that respect for the sovereignty, territorial integrity and political independence of every state is a fundamental principle of the Charter of the United Nations, any violation of which on any pretext whatsoever is contrary to its aims and purposes."

If the signers had in the past approved such a strong stand, would China have still invaded Vietnam last year? Would Tanzania have marched into Uganda to overthrow the despicable Idi Amin? Would France have intervened militarily in the Central African Empire to depose the ruthless Emperor Bokassa?

And will the United States, the chief sponsor of the resolution, in the future be inhibited from aggressions like the Bay of Pigs invasion or the military occupation of the Dominican Republic? Let us hope that all the signers will now start practicing what the Afghanistan resolution preaches.