The news this week that democracy is imperiled in Tunisia — the only success story of the Arab Spring — comes just three weeks after we heard that Haiti’s president had been assassinated. Meanwhile, in Afghanistan, the government seems unable to establish authority across the country. It got me thinking about one of the fundamental questions of politics: Why is it so difficult to develop and sustain liberal democracy?

The best recent work on this subject comes from a remarkable pair of scholars, Daron Acemoglu and James A. Robinson. In their latest book, “The Narrow Corridor,” they have answered this question with great insight. In every society, they note, the first step is simply achieving some measure of order and stability. History is littered with places where gangs, warlords and tribes rule and the state is never able to effectively consolidate power and govern. That was Afghanistan’s past and might be its future.

If political order is rare, liberal political order is rarer still. Liberal democracy is the Goldilocks form of government. It needs a state that is strong enough to govern effectively but not so strong that it crushes the liberties and rights of its people. The authors call this “the shackled Leviathan.” (Thomas Hobbes used the biblical monster Leviathan to describe a powerful state.) Getting to liberal democracy requires that societies travel through a “narrow corridor,” one that allows the state to build power while allowing for the growth of a civil society that asserts itself and fights for rights. Together, they create the delicate balance between stability and freedom. Countries in the West have succeeded because they have managed to build up both strong states and strong societies.

In Afghanistan, despite two decades of efforts, the state has failed to gain control over much of the country, creating what the authors call the “absent Leviathan.” In Egypt, the state is too strong. After a brief flirtation with democracy after the Arab Spring, the country reverted to dictatorship. Other parts of the world have “paper Leviathans” — governments that exercise power mostly to enrich a small elite at the top. Think of Nigeria or Venezuela.

How did the West get Goldilocks politics? The authors cite two opposing forces. First, there was the legacy of the Roman Empire, which provided institutions, laws and traditions that made it possible to create order. Second, the northern European tribes, rooted in egalitarian assemblies, had a tradition of challenging powerful leaders. The contest between nobles and kings — and later, I would add, between church and state, and among the hundreds of states, duchies and principalities of medieval Europe — all helped individual liberty grow and flourish.

It is not a matter of the West’s cultural superiority but rather its unusual history. Countries in other parts of the world have been able to strike a similar balance — India, South Korea, Costa Rica. But the corridor is narrow, and understanding that helps us to recognize the fragility of liberal democracy. That is why, in the late 1990s, while we were cheering as countries across the globe were holding elections, I identified the phenomenon of “illiberal democracy,” places where elected leaders were systematically abusing power, depriving people of their rights and hollowing out the essence of liberal, constitutional government. Since then, unfortunately, that list has gotten much longer, including Western countries such as Hungary, established democracies such as India, and some, such as Russia, that have simply morphed into dictatorships.

Countries — including the United States — that have traveled the narrow corridor and have struck the right balance between state and society are lucky. But we are in an era of democratic dysfunction, as populist movements threaten the political institutions and norms that have long been seen as neutral. We see this most dangerously in the Republican Party’s effort to politicize the counting of votes in the various states it controls.

The United States remains a liberal democracy, but this week’s hearing on the Jan. 6 insurrection at the Capitol highlighted the fragility of democratic norms even here. Our political institutions are stronger than most, but they are being strained by a society that is deeply divided — so much so that even the basic facts of what happened on Jan. 6 are being vigorously contested.

The rioters, egged on by unscrupulous politicians, showed how much damage a group of private citizens could do. But the rest of us can repair the damage by pushing for stronger democratic guardrails and resisting efforts to subvert the will of the people.

By now you’ve probably heard the story that, in 1787, someone supposedly asked Benjamin Franklin what kind of government the Constitutional Convention had decided on. “A republic,” he answered, “if you can keep it.” The delegates could have designed the best system in the world, but its success ultimately rested with the people.

That sounds like an ominous warning, but we might also take comfort — the power to preserve democracy is in our hands.