Arguments about the rights and wrongs of economic arrangements often lead us back to fundamental philosophical questions of what people morally deserve and why. The public furore over the financial crisis of 2008-2009 is a case in point. For years, stock prices and property values had climbed. The reckoning came when the housing bubble burst. Wall Street banks and financial institutions had made billions of dollars on complex investments backed by mortgages whose value now plunged. Once-proud Wall Street firms teetered on the edge of collapse. The stock market tanked, devastating not only big investors but also ordinary Americans, whose retirement accounts lost much of their value. The total wealth of American families fell by $11trn in 2008, an amount equal to the combined annual output of Germany, Japan and the UK.

In October 2008, President George W Bush asked Congress for $700bn to bail out the nation's big banks and financial firms. It didn't seem fair that Wall Street had enjoyed huge profits during the good times and was now asking taxpayers to foot the bill when things had gone bad. But there seemed no alternative. The banks and financial firms had grown so vast and so entwined with every aspect of the economy that their collapse might bring down the entire financial system. They were "too big to fail".

No one claimed that the banks and investment houses deserved the money. Their reckless bets (enabled by inadequate government regulation) had created the crisis. But here was a case where the welfare of the economy as a whole seemed to outweigh considerations of fairness. Congress reluctantly appropriated the bailout funds.

Then came the bonuses. Shortly after the bailout money began to flow, news accounts revealed that some of the companies now on the public dole were awarding millions of dollars in bonuses to their executives. The most egregious case involved the American International Group (AIG), an insurance giant brought to ruin by the risky investments of its financial products unit. Despite having been rescued with massive infusions of government funds (totalling more than $180bn), the company paid $165m in bonuses to executives in the very division that had precipitated the crisis. Seventy-three employees received bonuses of $1m or more.

News of the bonuses set off a firestorm of public protest. The outrage was about lavish rewards subsidised with taxpayer funds to members of the division that had helped bring the global financial system to near-meltdown. Something was wrong with this picture. Although the US government now owned 80 per cent of the company, the treasury secretary pleaded in vain with AIG's government-appointed chief executive to rescind the bonuses. "We cannot attract and retain the best and the brightest talent," the CEO replied, "if employees believe their compensation is subject to continued and arbitrary adjustment by the US treasury." He claimed the employees' talents were needed to unload the toxic assets for the benefit of the taxpayers, who, after all, owned most of the company.

The public reacted with fury. A full-page headline in the tabloid New York Post captured the sentiments of many: "Not so fast, you greedy bastards". The US House of Representatives sought to claw back the payments by approving a bill that would impose a 90 per cent tax on bonuses paid to employees of companies that received substantial bailout funds.

Under pressure from the New York attorney general Andrew Cuomo, 15 of the top 20 AIG bonus recipients agreed to return the payments, and some $50m was recouped in all. This gesture assuaged public anger to some degree, and support for the punitive tax measure faded in the Senate. But the episode left the public reluctant to spend more to clean up the mess the financial industry had created.

At the heart of the outrage was a sense of injustice. Even before the bonus issue erupted, public support for the bailout was hesitant and conflicted. Americans were torn between the need to prevent a meltdown that would hurt everyone and their belief that funnelling massive sums

to failed banks and investment companies was deeply unfair. To avoid economic disaster, Congress and the public acceded. But morally speaking, it had felt all along like a kind of extortion.

Underlying the bailout outrage was a belief about moral desert: the executives receiving the bonuses (and the companies receiving the bail­outs) didn't deserve them. But why didn't they? The reason may be less obvious than it seems. Consider two possible answers - one is about greed, the other about failure.

One source of outrage was that the bonuses seemed to reward greed, as the tabloid headline indelicately suggested. The public found this morally unpalatable. Not only the bonuses but the bailout as a whole seemed, perversely, to reward greedy behaviour rather than punish it. The derivatives traders had landed their company, and the country, in dire financial peril -by making reckless investments in pursuit of ever-greater profits. Having pocketed the profits when times were good, they saw nothing wrong with million-dollar bonuses even after their investments had come to ruin.

The greed critique was voiced not only by the tabloids, but also (in more decorous versions) by public officials. Senator Sherrod Brown (Democrat-Ohio) said that AIG's behaviour "smacks of greed, arrogance and worse". President Obama stated that AIG "finds itself in financial distress due to recklessness and greed".

The problem with the greed critique is that it doesn't distinguish the rewards bestowed by the bailout after the crash from the rewards bestowed by markets when times were flush. Greed is a vice, a bad attitude, an excessive, single-minded desire for gain. So it is understandable that people aren't keen to reward it. But is there any reason to assume that the recipients of bail­out bonuses are any greedier now than they were a few years ago, when they were riding high and reaping even greater rewards?

Wall Street traders, bankers and hedge-fund managers are a hard-charging lot. The pursuit of financial gain is what they do for a living. Whether or not their vocation taints their character, their virtue is unlikely to rise or fall with the stock market. So if it's wrong to reward greed with big bailout bonuses, isn't it also wrong to reward it with market largesse? The public was outraged when, in 2008, Wall Street firms (some on taxpayer-subsidised life support) handed out $16bn in bonuses. But this figure was less than half the amounts paid out in 2006 ($34bn) and 2007 ($33bn). If greed is the reason they don't deserve the money now, on what basis can it be said they deserved the money then?

One obvious difference is that bailout bonuses come from the taxpayer while the bonuses paid in good times come from company earnings. If the outrage is based on the conviction that the bonuses are undeserved, however, the source of the payment is not morally decisive. But it does provide a clue: the reason the bonuses are coming from the taxpayer is that the companies have failed. This takes us to the heart of the complaint. The American public's real objection to the bonuses - and the bailout - is not that they reward greed but that they reward failure.

Americans are harder on failure than on greed. In market-driven societies, ambitious people are expected to pursue their interests vigorously, and the line between self-interest and greed often blurs. But the line between success and failure is etched more sharply. And the idea that people deserve the rewards that success bestows is central to the American dream.

Notwithstanding his passing reference to greed, President Obama understood that rewarding failure was the deeper source of dissonance and outrage. In announcing limits on executive pay at companies receiving bailout funds, Obama identified the real source of bailout outrage:

“This is America. We don't disparage wealth. We don't begrudge anybody for achieving success. And we certainly believe that success should be rewarded. But what gets people upset - and rightfully so - are executives being rewarded for failure, especially when those rewards are subsidised by US taxpayers."

One of the most bizarre statements about bail­out ethics came from Senator Charles Grassley (Republican-Iowa), a fiscal conservative from the heartland. At the height of the bonus furore, Grassley said in an Iowa radio interview that what bothered him most was the refusal of the corporate executives to take any blame for their failures. He would "feel a bit better towards them if they would follow the Japanese example and come before the American people and take that deep bow and say, 'I'm sorry,' and then do either one of two things - resign or go commit suicide".

Grassley later explained that he was not calling on the executives to commit suicide. But he did want them to accept responsibility for their failure, to show contrition and to offer a public apology. "I haven't heard this from CEOs, and it just makes it very difficult for the taxpayers of my district to just keep shovelling money out the door," he said.

Grassley's comments support my hunch that the bailout anger was not mainly about greed; what most offended Americans' sense of justice was that their tax dollars were being used to reward failure.

If that's right, it remains to ask whether this view of the bailouts was justified. Were the CEOs and top executives of the big banks and investment firms really to blame for the financial crisis? Many of the executives didn't think so. Testifying before congressional committees investigating the financial crisis, they insisted they had done all they could with the information available to them. The former chief executive of Bear Stearns, a Wall Street investment firm that collapsed in 2008, said he had pondered long and hard whether he could have done anything differently. He concluded he'd done all he could. "I just simply have not been able to come up with anything . . . that would have made a difference to the situation we faced."

Other CEOs of failed companies agreed, insisting that they were victims "of a financial tsunami" beyond their control. A similar attitude extended to young traders, who had a hard time understanding the public's fury about their bonuses. "There's no sympathy for us anywhere," a Wall Street trader told a reporter for Vanity Fair. "But it's not as if we weren't working hard."

The tsunami metaphor became part of bailout vernacular, especially in financial circles. If the executives are right that the failure of their companies was due to larger economic forces, not their own decisions, this would explain why they didn't express the remorse that Senator Grassley wanted to hear. But it also raises a far-reaching question about failure, success and justice. If big, systemic economic forces account for the disastrous loses of 2008 and 2009, couldn't it be argued that they also account for the dazzling gains of earlier years? If the weather is to blame for the bad years, how can it be that the talent, wisdom and hard work of bankers, traders and Wall Street executives are responsible for the stupendous returns that occurred when the sun was shining?

Confronted with public outrage over paying bonuses for failure, the CEOs argued that financial returns are not wholly their own doing, but the product of forces beyond their control. They may have a point. But if this is true, there's good reason to question their claim to outsized compensation when times are good. Surely the end of the cold war, the globalisation of trade and capital markets, the rise of personal computers and the internet, and a host of other factors help explain the success of the financial industry in the 1990s and in the early years of the 21st century.

In 2007, CEOs at major US corporations were paid 344 times the pay of the average worker. On what grounds, if any, do executives deserve to make that much more than their employees? Most of them work hard and bring talent to their work. But consider this: in 1980, CEOs earned only 42 times what their workers did. Were executives less talented and hard-working than they are today? Or do pay differentials reflect contingencies unrelated to talents and skills?

Or compare the level of executive compensation in the United States with that in other countries. CEOs at top US companies earn an average of $13.3m per year (using 2004-2006 data), compared to $6.6m for European chief executives and $1.5m for CEOs in Japan. Are American executives twice as deserving as their European counterparts, and nine times as deserving as Japanese CEOs? Or do these differences also reflect factors unrelated to the effort and talent that executives bring to their jobs?

The bailout outrage that gripped the United States in early 2009 expressed the widely held view that people who wreck the companies they run with risky investments don't deserve to be rewarded with millions of dollars in bonuses. But the argument over the bonuses raises questions about who deserves what when times are good. Do the successful deserve the bounty that markets bestow upon them, or does that bounty depend on factors beyond their control? And what are the implications for the mutual obligations of citizens - in good times and hard times? Whether the financial crisis will prompt public debate on these broader questions remains to be seen.

Michael Sandel is Bass Professor of Government at Harvard University. His book "Justice: What's the Right Thing To Do?" will

be published by Allen Lane on 24 September (priced: £14.99)

Read Jonathan Derbyshire's interview with Michael Sandel here