TEMPORARY THOUGH it may turn out to be, the rescue of the dollar was very much worth the cost. That cost was high. In recent days the major industrial countries have put several billion dollars into their joint attempt to stabilize exchange rates. But to have let the dollar continue to fall, while governments stood by carelessly with their hands in their pockets, would have invited a disaster.

A few economists who ought to know better have been jauntily recommending that the United States forget the exchange rates and protect its own domestic economy. The trouble with that prescription is that the domestic economy is not separable from the rest of the world. Surely one of the great lessons of the 1930s was the impossibility of protecting the prosperity of any country, even the most powerful, if the worldwide financial and trade system goes into collapse. National economies are far more interwoven now than in the 1930s, and the dollar remains the world's central currency.

The danger, as it developed in the last week of December, was the growing assumption among currency traders that the dollar would continue to slide unimpeded. Speculation against the dollar seemed increasingly safe. If it appeared to be certain that the dollar was going to fall by another 10 percent against the yen and the mark before the end of 1988, why would any competent money manager leave capital in this country?

Capital flight is an affliction not limited to underdeveloped Latin countries. Both Britain and France suffered it at least briefly in recent memory, and the neglect of the exchange rates has now left the United States vulnerable. The tremendous American trade deficits of the past six years have been financed by a flow of hundreds of billions of dollars of foreign capital -- European, Japanese and Latin -- into this country. Some of it is very long-term industrial investment, like the factories that the Japanese auto companies are building here. But by far the greatest part of that money is parked uneasily in banks and the securities markets from which its owners could recall it by telex in a matter of hours. There is no sign of any significant withdrawal so far. But if a run on the dollar were to get started, it would be exceedingly difficult and expensive to stop. The several billion dollars worth of currency intervention in the past few days has singed the speculators, reassured the foreign investors and told the world that betting against the dollar is not quite such a sure thing as it seemed last week.

And yet the fundamental source of strain continues. Even if next week's monthly trade statistics show improvement, the U.S. trade deficit this year is probably going to remain over $150 billion. That means that to hold the dollar steady through the year will require $150 billion of foreign financing. Where's it going to come from? The private investors have now largely stopped further lending, leaving only governments -- chiefly Japan's and West Germany's. The only way to get the trade deficit down fast is the recession that the administration is desperately trying to stave off in an election year. It remains very much an open question whether Japan and West Germany are able or willing to invest enough of their countries' money in the dollar to finance election-year prosperity for the United States.