Jimmy Carter limped out of the White House complaining of "the attrition of the presidency." Ronald Reagan, after his reelection, exulted: "It's only the beginning."

The two comments express a well nigh universal perception that Reagan has revived a great office of state. But why has he been such a tonic for the job? And how long will the recovered presidency endure?

Personality explains much of the transformation. Likable presidents -- from Roosevelt through Kennedy -- gave the office its good name in the modern period. Reagan is far and away the most attractive figure to serve in the White House since Kennedy. Face-to-face, he radiates charm. In public appearances, he beams with good will. Even when he talks tough, he is not threatening. So he attracts good feeling to himself, and much of it rubs off on the presidency.

Ability to communicate well with an audience of millions also counts for a lot. Lyndon Johnson was overbearing. A sinister element figured in everything Nixon ever said. Ford bumbled. Carter, a moralist, never set clear priorities.

By comparison, Reagan has picked a very few themes -- cutting taxes, shrinking government, standing up for America, and the old values. All of them command huge majorities to start. They are further enhanced by sophisticated marketing techniques. Then Reagan makes them his own priorities either in well-delivered speeches of sparkling prose or, even better, by dramatic actions, such as visiting the beaches on the 40th anniversary of D-Day.

Ideology reinforces clarity. Not many Americans are bright enough or dumb enough to share Reagan's enthusiasm for supply-side economics or the devil theory of Soviet communism. But a leader armed with such views gives the appearance of no-nonsense cold-turkeyism. Americans in recent years have come to prefer that kind of blind commitment over the ambiguous opportunism that marked the performance of such recent presidents as Carter, Ford, Nixon and Johnson.

Luck, never far from the fate of leaders, as Machiavelli constantly reminds, made it safe to be ideological. Deaths in the Kremlin left Reagan untested by a solid Russian leadership. The American economy rebounded from the worst postwar recession with great force and at a time -- 1983-84 -- that put Reagan's somewhat dubious theories and performance beyond practical, political questioning.

But luck, as Branch Rickey used to observe, is the "residue of design." A special feature of the Reagan administration has been a capacity to avoid getting hooked on long-term losers. One cannot imagine this president caught up in the toils of a Vietnam, or a Watergate, or a presidential pardon, or an Iranian hostage crisis. More than any president I can remember, Reagan has developed the trick of avoiding disaster.

The president himself is the visible part of the trick. As a skilled actor, never deeply involved in the substance of policy, he can change directions rapidly, without giving the impression of change to the public or -- it often seems -- himself. Lebanon, of course, is the shining example. One day Reagan was insisting that a strong American stand in Beirut was a test of this country's fidelity to allies everywhere. The next day he ordered what amounted to an ignominious retreat. But he was off the hook, and, as it happened, the jumble of bits and pieces in Lebanon maintained a screen of confusion that covered the American bug-out.

Similar turnarounds took place less dramatically. Reagan went back on his enthusiasm for Taiwan in agreeing to a Chinese proposal that American arms shipments to Taipei level off. He bowed to dovish opinion in toning down the anti-Soviet rhetoric of the first thre years. He flipped on the environment, and did a double flip-flop on acid rain.

If acting skill is necessary up front, somewhere out of sight there is sensitive perception. Many White House staff people -- notably Jim Baker, Mike Deaver and Richard Darman -- were quick to spot potential banana peels and edge the president away. Secondhand reports from the White House indicate that Nancy Reagan has been particularly allergic to developments that might make the president look bad. She evidently played a key role in the removal of Alexander Haig as secretary of state (because of Lebanon) and William Clark as national security adviser (because of Central America).

A weakening of this anti-disaster mechanism is one change already evident as the second Reagan administration takes shape. With the departure of Deaver, Mrs. Reagan has lost her main pipeline to the staff. Sensitivity to advance trouble is thus doubly diminished.

That falling-off could be important if the luck breaks. A Reagan administration that did nothing about closing the budget deficits could go over the cliff. But as the second term begins, the perils of high deficits, high interest rates and high trade imbalances are all too apparent. Opportunities are equally apparent. The administration is on the high road to arms control and tax reform. So the odds are good -- until 1987 at least -- for a successful second term and a continuing glow around the presidency.