UNDER THE Reagan administration, the Environmental Protection Agency has had the worst administrator of its short history, and the best. The second, William D. Ruckelshaus, is now leaving because, he says, he has done the job that he came back to the EPA to do. Having repaired the damage that the agency suffered during the unhappy tenure of his predecessor, Anne M. Burford, he now leaves it in as good shape as it's ever been -- and perhaps better. He has restored the EPA's sense of mission and its integrity. He has recruited able people. It's been a remarkable achievement.

Then why is he leaving? He says that there's no quarrel with the White House over either budget or policy. Perhaps he's going because the administrator, over the next four years, is likely to spend most of his time on routine enforcement of laws that aren't going to change much. The standoff between the White House and Congress will ensure that. The quality of vigor of that enforcement will be highly important to the country's health, but Mr. Ruckelshaus is content to leave it to someone else. In nominating one of his deputies, Lee M. Thomas, the president has voted this time for continuity and competence.

That's reassuring, for this agency -- not very large, as federal agencies go -- casts an immense influence. At a moment in which the annual budget struggle is at the center of political attention here in Washington, the EPA offers a useful reminder that the line between federal and private spending is not always as clear as it seems. This country now spends nearly $60 billion a year on pollution abatement and control -- most of it under the laws that the EPA administers. Only $4 billion of it is federal money. The rest? It's spent by private businesses, consumers, and state and local governments. Private money spent to meet a public requirement is a tax, and the government has the same duty to spend it wisely as it does any other kind of tax money.

That was one of Mr. Ruckelshaus' special concerns -- to develop the analytical ability at EPA to see that the last dollar would be spent where it could do the most good. Most of the environmental lobbies detest the idea of cost-benefit analysis, but it's much too useful a principle to neglect.

In the immediate future, EPA's most urgent work will probably lie in the fields of protecting water quality and in cleaning up toxic wastes. The two are related, since it's often the chemical dump that is the threat to the water supply. This essential work is well begun. But to keep it going will take stamina and determination, not to mention a lot more money.