BOSTON— It was 1974 when scientists first calculated that chemicals used in aerosol sprays and other products would deplete the earth's ozone layer. The Du Pont Company, dismissing the finding as ''speculative,'' fought proposed legislation. To restrict the chemicals ''would cause tremendous economic dislocation,'' a Du Pont official said.

Today just about everyone agrees that we must stop using those chemicals. Du Pont has begun to phase out production. But the resistance by Du Pont and others helped to cause 15 years of dangerous additional damage to the ozone layer.

The moral of that story is an unhappy one. In a democratic society, where the economic motive is strong, it is extremely difficult to give up short-term economic benefits for a long-term reason - even a compelling reason, one of life and death.

The same point underlies the latest controversy about government handling of environmental challenges. That is the flap about official rewriting of scientific testimony on global warming.

James E. Hansen, director of the National Aeronautics and Space Administration's Goddard Institute for Space Studies, prepared a statement on global warming for a Senate hearing. It dealt with the greenhouse effect, changes in climate caused by carbon dioxide and other gases re-leased into the atmosphere in modern industrial societies.

Dr. Hansen's testimony was in the nature of an extremely serious warning. He said computer projections showed that there would be substantial rises in temperature, drought and severe storms. Those changes, he said, would affect the earth's biological systems.

He submitted the text in advance to the White House's Office of Management and Budget, which is supposed to make sure that high officials hew to established policies. But in this case the office rewrote Dr. Hansen's scientific conclusions.

For example, Dr. Hansen said he believed that gases causing the greenhouse effect came primarily from human activities, such as burning coal and oil and destroying rain forests. The budget office rewrote that section to say that the relative contribution of man's activities and of natural processes to the greenhouse effect ''remains scientifically unknown.''

''They are scared of the truth,'' Senator Albert Gore Jr. said of the budget officials. No doubt they are. For recognizing the seriousness of the global warming trend - its threat to life on earth - would require swift and painful adjustments.

Burning fossil fuels, the coal and oil that mostly propel and heat our societies, adds carbon dioxide to the atmosphere. Carbon dioxide and other heat-reflecting gases are believed to cause the greenhouse effect.

So if the prospect of global warming is taken seriously, we need urgently to reduce our use of fossil fuels. Merely to state that is to understand how daunting the task is. It would call for enormous efforts at energy conservation and development of alternative sources such as solar energy.

The essential challenge is to political leadership. And the record on that front gives little ground for optimism.

The official censorship of Dr. Hansen's testimony this week was not the first such incident, in fact. In 1987 the Reagan budget office made him remove a recommendation for increased research on global warming. The episode was described last January in an article by Dick Russell in the weekly In These Times.

The Reagan Administration ran away from long-term environmental challenges, slashing research and other funds. In this as in other areas it left the price to be paid by future generations.

But the Reagan years were only an extreme expression of a tendency inherent in democratic societies. That is for politicians to gratify the immediate desires that dominate the thinking of their constituents. To build a constituency for long-range necessities is difficult.

Leszek Kolakowski, professor of philosophy at the University of Chicago, made the point recently at a meeting held by the National Endowment for Democracy. Economic growth, he said, has produced a ''mentality of endless expectations. Somehow we got used to the hope that each of us is going to have more and more of everything. . . .''

Our ''needs,'' Professor Kolakowski said, ''can and do expand indefinitely along the endless spiral of greed.'' How will democracy cope as we are forced to give up some personal gratifications in order to repair the planet and ward off calamities?