It is easy to forget how desperate things were on Jan. 20, 2021, when Joseph Robinette Biden Jr. became the 46th president of the United States.

Just two weeks earlier, thousands of President Donald Trump’s supporters had stormed the U.S. Capitol in a violent attempt to keep Congress from certifying Biden’s election victory. The nation was at the height of the coronavirus pandemic; in that month, 3,000 Americans died daily from COVID-19. There were newly developed, lifesaving vaccines, thanks to the Trump administration’s Operation Warp Speed — but there was no viable plan to distribute them. Schools and workplaces were shuttered; hotels and airlines had no customers; restaurants tried to survive by offering take-out. The U.S. economy and the world economy were on life support.

Four years later, the country is in vastly better shape, at home and abroad. The economy, though still recovering, is the envy of the developed world; U.S. stock markets are at or near all-time highs. Our political system has survived. We have made overdue investments in infrastructure and technology. And in a world full of conflict and danger, American troops are not at war for the first time in a generation.

History may fault Biden for the way his term in office ended. By any objective standard, however, he was a very good president whose accomplishments will benefit the nation for many years to come.

On the economy, Biden’s record is remarkable. When Biden became president, joblessness had eased considerably but was still elevated at 6.3 percent. Unemployment declined steadily during Biden’s first year in the White House until, in December 2021, it dipped to just 3.9 percent — and remained at or below 4 percent for 30 straight months. Biden’s was a “jobs, jobs, jobs” economy.

In an era of bitter partisanship and polarization, Biden passed a $1.2 trillion infrastructure bill, to go along with victories on climate change and gun legislation, and the Chips and Science Act.

Without question, the United States’ withdrawal from Afghanistan in 2021 was chaotic and tragic. Thirteen American service members were killed in a terrorist attack amid a sudden collapse of public order in Kabul that Biden and his planners should have anticipated.

That mistake cost Biden dearly in public support. It also obscured the administration’s subsequent foreign policy successes.

Why, then, does Biden have an approval rating that struggles to reach 40 percent? Why did he have to end his campaign for reelection, abandoning a race he still thinks he could have won? What was his unforgivable sin?

Actually, there were two. One sin was political: Biden failed to address the crisis at the southern border — failed, even, to recognize it as a crisis — until far too late. By the time he finally took executive action that calmed the chaos, the immigration issue had become a millstone he could never remove.

The other sin was actuarial: Biden got old. Worse, he showed his age, reaching the point where he walked and talked unsteadily. None of that said anything about his thinking, but no matter. Voters had the right to decide he looked and sounded too feeble to be president for four more years.

But I am confident that historians, with the clarity of hindsight, will focus less on Biden’s softening voice and tentative gait — and more on all that he managed to achieve in a single term. He was a consequential and farsighted president who leaves the nation much better off than he found it