JUST AS A price-inflating drought in 1974 helped make Richard Nixon's secretary of agriculture, Earl L. Butz, such a favorite among farmers, the drought of 1983 is giving the Reagan administration a nice timely boost in farm country.

With the heat that has wilted the corn and soybean crops, prices have gone up steadily and supplies appear likely to be reasonably balanced with demand after this year's harvest.

The irony is that that it's actually a Jimmy Carter legacy that ultimately may help Ronald Reagan save his political skin with farmers and consumers alike in the 1984 presidential year, assuming he's a candidate.

That legacy is called the farmer- owned grain reserve, a tool that, however distasteful to Reagan's free-market philosophers, turns out to be their ace in the hole.

Pure and simple, the reserve is a way for government to manage the agricultural economy -- the antithesis of the Reagan administration's idea that government ought to get out of agriculture, let free markets dictate and let farmers produce. Secretary of Agriculture John Block rarely appears in public without repeating that theme.

Yet twice the reserve has saved Reagan and Secretary John R. Block from themselves. When Block refused to set up a strong crop-reduction program for 1982, the harvest came out a whopper and surplus problems intensified. Much of that excess corn went into the reserve and averted a total price collapse, although it sent federal farm-support loan costs soaring.

And now, the grain reserve is helping the administration wriggle free from the problems created by the weather and its own policies. Grain output is going to be sharply down this year not only because of the drought but also because of the administration's payment-in-kind (PIK) program that gives farmers surplus corn for not planting more of the grain.

If Jimmy Carter had not set up the farmer-owned grain reserve, Ronald Reagan would be in a lot more trouble than he already is in. The reserve helps Reagan several ways. It provides a source of grains that can be turned over to farmers in the PIK program. This helps the White House hold down direct government outlays to farmers in the form of price support loans.

Beyond that, the reserve could help Reagan head off even worse trouble: a really dramatic rise in food prices during the 1984 election year. It may enable him to avoid the usual calculus of farm politics, which is that when the farmers are happy now the consumers are likely to be unhappy later. That happened after farm prices took off in the early 1970s.

The Carterites set up the reserve early in 1977 at a time when wheat harvests were good and farm prices were falling. The idea was to keep grain off the market by storing it on farms, strengthening prices and averting more roller-coaster effects on food prices.

Congress liked the idea and wrote it into the 1977 farm bill, expanding it to cover other grains. Farmers would get three-to five-year loans and federal storage payments if they participated to keep excess supplies off the market. When prices went up, they would be free to pay off the loans and sell their grain.

Carter's secretary of agriculture, Bob Bergland, called the reserve the "hare-brained idea" of his chief economist, Howard Hjort. A bit later, as it started looking better, Bergland was calling it his own idea. And later it was so good that it came to be called "the Carter reserve."

Farmers had mixed views about it. Some, fearing government manipulation that might keep prices down, saw it as a cloud over their markets. Its supply-management feature appealed to others, who jumped at the chance to get low-cost loans to build new storage facilities on the farm.

The reserve, by then an important element in the federal farm-support net, was extended by Congress in the 1981 farm bill. Block wasn't ecstatic about it, but he backed the reserve as a device to "protect against extreme fluctuations in grain supplies and prices . . . that our livestock producers and our foreign customers, domestic customers, too, can be assured of a reliable source of supply."

But even at that, this supply-side administration was lukewarm to the reserve. Lately there has been talk that Reagan policy makers would like to do it in. And USDA has tightened the rules for participation in it.

This is ironic when you consider what a valuable buffer the reserve can be for Reagan when the toll of this summer's heat is added up and critics begin their caterwauling.

The reserve has been functioning pretty much the way it was intended to. It is evening out the boom-and- bust cycle that traditionally has battered the farm economy -- and consumers -- and caused grief to American presidents who have been unable to strike a balance between the interests of the two.

This isn't to say there won't still be winners and losers, even though the pain might be worse without it.

Higher feed-grain prices mean that meat producers will cut their herds. They will be losers. For the short run, with more meat on the market and prices down somewhat, consumers win. In the longer run, probably in late 1984, prices will head back up. Score that for the farmers and ranchers.

And higher feed prices mean that dairymen will cut their herds, reducing the overproduction that will cost taxpayers about $2.5 billion this year just to get surplus milk, butter and cheese off the market. Dairymen lose; taxpayers win.

Farmers may even see some extra income, although higher prices and the continued strong dollar do not augur well for the increased exports they think they need to prosper.

To complete the circle of election- year ironies, consider this: Most farm experts believe that the administration's likely abandonment of aacorn PIK for 1984 and the scaled down wheat PIK already announced (too late to help many farmers, by the way) will lead to more bin-busting planting and harvests next year.

Reagan and Block could be right back where they started. If so, they'll still have Jimmy Carter's reserve to get them off the hook, but don't expect a thank you. It's not the free- market agriculture they keep talking about.