Democracies and brutal dictatorships alike have managed to industrialize their economies, but freedom and the rule of law have been essential for the jump into advanced prosperity. Singapore is arguably the sole, tiny (population: 4.3 million) exception to that rule; China’s Communist Party is betting it can shape the first giant one.

But how well does democracy work once countries enter what you might call the AARP stage of life? We don’t know. It’s the key question reflected in the political turmoil roiling Europe, Japan and the United States.

In all three, economies are slowing and populations are aging. In the 34 advanced democracies that make up the Organization for Economic Cooperation and Development (OECD), there are on average 4.2 people of working age (20 to 64) for every one who is 65 or older. By 2050, OECD projects the ratio will be down to 2.1 to 1.

That’s a stark decline, and it helps explain why politics in Berlin, Tokyo and, not least, Washington are so difficult. The only hope for an AARP society is to keep investing in children’s health, schools and colleges, roads, rail, fiber optics, and research and development to stoke economic growth.

A lot of that investment has to come from the private sector, but a lot has to come from government. That in turn requires sufficient revenue (which many Republicans oppose) and making sure that future-oriented spending isn’t crowded out by pension and retiree health costs (which, by blocking any entitlement reform, many Democrats oppose). So in different ways, both American parties are representing the interests of the past and present against the future — and the constituency of the future is growing, proportionately, smaller and smaller.

What’s both encouraging and frustrating about the debate that has Washington tied up in knots is that America is better off than most other countries, and its problems more solvable. With strong political leadership the country still has the potential to be prosperous and powerful for a long time.

Start with the basics: ample space (we’re the world’s third-biggest country); sizable population (also third in the world); natural resources; a friendly neighborhood; and wealth virtually unmatched in history or geography.

U.S. total economic output, or GDP, was $47,186 per person in 2008, compared with $33,748 for the OECD as a whole. Among those 34, only Norway and Luxembourg’s were higher. U.S. income is less equally shared than it should be, but a poor American is still wealthier than an average Chinese, whose per capita GDP was $7,600 in 2010, according to the CIA World Factbook.

And thanks to immigration and a higher birth rate, the United States is better off than most advanced countries when it comes to the aging of its population. There are 4.7 working-age Americans for every one of retirement age today, compared with only 2.8 in Japan. And even in 2050, the OECD estimates that the U.S. ratio will be 2.6, more favorable than the OECD average and far higher than Japan’s astonishing 1.2.

Still, in some key measures, the United States is weakening: in college completion rates, investment in roads and other infrastructure, and, crucially, in accumulation of government debt. What unites those three things is AARP-stage thinking: It’s the next generation that will pay the debt, drive the pitted roads and suffer declining prosperity due to inadequate education. And there are comparable stories in Europe, slow to tackle its debt crisis because taxpayers in Germany (ratio 3.0) aren’t keen to pay pension costs in Greece (ratio: 3.4), and Japan, where an increasingly dysfunctional political system can’t make the reforms that might promote growth but that discomfort the aging majority.

There’s no reason to think that non-democracies will handle this challenge better. As Nicholas Eberstadt of the American Enterprise Institute has pointed out, China, most frequently cited as America’s 21st-century rival, will be the first country to be simultaneously aging and developing, in part because its rigidly enforced one-child rule has already reduced its worker-to-retiree ratio to 8 (compared with 10 in Indonesia and 11 in India) and will help bring it to 2.4 in 2050, according to the OECD.

Moreover, the Chinese Communist Party will fret over its legitimacy as long as it deprives people of political liberty and so may find itself more prone to economic populism — to satisfying the demands of today over tomorrow — as its population ages.

But a failure of autocracy would be no comfort to democracies that can’t rise to their challenge. It’s true, as Eberstadt writes, that “demography need not be economic destiny,” but overcoming the political challenge imposed by demography means appealing to voters’ larger sense of patriotism, and their hopes for their children and grandchildren, above the special interests that fan the I-want-mine mentality and the parties that can thrive on the fears of older voters.

That’s a lot to ask of Barack Obama and John Boehner. But it is what the country needs.