Effective or not, bailouts somehow seem unjust. Why use taxpayer money to save the companies that actually caused the meltdown, the banks that made the reckless loans, and insurance companies that wrote too many credit- default swaps? More broadly, why save the state and local governments that offered overly generous pensions? Or auto companies too fat and lazy to match foreign competitors? They deserve to suffer the consequences of their behavior.

Let’s start with the word “bailout.” To most laypeople, it suggests a gift to a giant, inefficient, highly connected octopus. But bailouts are typically investments: loans or purchases. In 1980, the U.S. government bailed out Chrysler with a $1.5 billion loan and earned acid criticism, mostly from liberals. But by 1983, Chrysler had paid it back and, with interest and stock warrants, the government made a $660 million profit. Taxpayers spent less overall, and the nation saved jobs. So these companies often pay for the lifesaver we throw them.

More basically, the trouble is that we don’t live in Adam Smith’s village. We live in a much larger world.

Take American International Group Inc. The mammoth insurer had links everywhere. On Feb. 28, 2008, it had branches in 130 countries and received half of its revenue from overseas. Its assets exceeded $1 trillion and its stock sold for $50.15. Yet for an insurance company it showed breathtaking disregard for risk. In August 2007, Joseph Cassano, head of the unit that made the fateful CDS deals, said, “It is hard for us, without being flippant, to even see a scenario within any kind of realm of reason that would see us losing one dollar in any of those transactions.”

Facing Bankruptcy

In late 2008, AIG faced death from “those transactions” and begged for help. The government could have punished it and let it succumb, but the harm would have been global. AIG owed money everywhere, and its bankruptcy could have brought surprising creditors, like the supposedly safe money-market funds, to their knees and spurred further panic.

Yet most AIG divisions earned a profit. So to keep this crumbling tower upright, the U.S. government pumped $182.5 billion into it and took 77.9 percent of its stock. The gamble seemed hazardous, since at one point its stock fell to about $1 a share. And it was the most hated bailout, partly because AIG went on to shower millions in bonuses on executives who had caused the fiasco.

But the strategy had key advantages. For instance, the government was buying inexpensively, when most investors thought the company mortally ill. And it could be patient. It didn’t need repayment at once. According to one analysis, by 2012 the U.S. government had earned all its money back and made a profit of $15 billion, and it still owned 16 percent of a company whose stock was selling for about $34.

Similarly, with the banking system, the most direct strategy would have been to take control of the most overleveraged big banks, fire the top executives, strip out the toxic assets and liquidate them slowly, and spin off new banks with cleansed balance sheets. This approach worked well in the U.S. savings-and-loan crisis of the 1980s and more recently for banks in Scandinavia. Taxpayers ended up paying relatively little, and the economy suffered minimal damage.

However, like all investments, bailouts don’t always turn a profit. The Treasury gave the big banks about $230 billion from the Troubled Asset Relief Program and has received about $255 billion, for a gain of $25 billion. However, the smaller banks still owe some $15 billion, and overall the public may never get the full $700 billion back from TARP. But its cost will be far less than pundits originally warned.

Saving Goliaths

So we have to counter the moral impulse to pull down irresponsible goliaths with the economic — and ultimately moral — benefits of saving them. After a financial crash, well- targeted bailouts and stimulus spending can hasten repair of the torn network. They can keep the economy stronger, spare the hardship of lost jobs, and earn money for taxpayers. The moral reaction, often manipulated to political advantage, hinders such repair work and prolongs the suffering.

The government can respond by educating the public about the nature of bailouts and thus help overcome the sense that they are ripping money from citizens’ paychecks to cushion fat cats from their blunders. This task may be difficult, but even so, Barack Obama’s administration proved deficient in it. Indeed, in the 2010 midterm elections, the moral backlash fueled the Tea Party and made further stimulus impossible. Repair of the financial system then had to proceed slowly, using awkward indirect subsidies.

The problems in the financial sector begin with bad promises at the base of the mortgage pyramid. A mortgage is a promise of monthly payments or an early repayment in full. That pledge is good as long as the owner can sell the house for more than the remaining principal balance of the mortgage. But when she no longer can — when she owes more than the house is worth — the promise is in jeopardy. She may do better by defaulting. And after 2007, falling home prices in much of Florida, California and elsewhere pulled millions of homeowners “underwater.” Monthly payments stopped from those who lost their jobs or were never able to pay to begin with.

But here is the interesting and important question: What about the underwater homeowners who can make the monthly payments? The value of a good credit rating and the possibility of a rebound in house prices might make it financially advantageous for them to keep paying on homes that are worth only slightly less than the value of their mortgage. At some point, however, it may make bottom-line sense to walk away from the loan.

Foreclosure Threat

The specter of massive foreclosures worried both politicians and economists. As a result, the Obama administration offered many programs to renegotiate distressed mortgages, some carved out of TARP funds and others created separately.

And that raised questions. Is it moral to use taxpayer money to ease the mortgages of people who should have understood and avoided them in the first place? Doesn’t every homeowner take a risk that the property’s value will decrease?

There is a moral tension here. On the one hand, most of us feel a desire to aid others in distress. On the other, we have homeowners with varied levels of culpability and merit — from the “good people” who received typical mortgages and wound up underwater anyway, to those who trusted lying agents and signed mortgages with nasty provisions they didn’t know about, to those who lied to get mortgages they couldn’t pay back. The weights you place on helping out versus punishing in each case reflects your moral attitude.

But here, too, we have to be careful not to let our moral instincts outweigh good policy. So what are the economic dimensions of this situation?

Businesses routinely walk away from contracts when it is more profitable to, and we hear no uproar about it. Moreover, the law imposes no punitive damages on anyone breaking a contract (in most cases). If you default, you pay only for the harm you cause, and the courts pass no moral judgment on you. The rationale is that our economy ultimately benefits, since business moves faster and more nimbly.

Homeowners whose mortgages are sufficiently underwater are in a similar situation. By defaulting, they can enjoy living in a home at lower cost, even taking into account the impact on their personal credit rating and the loss of the tax advantages from home ownership. And, they may argue, what’s the harm to anyone else?

But this dynamic changes when a tide of defaults looms. The more defaults, the more foreclosures, and they bring down the price of all homes nearby. If foreclosures are nationwide, people’s wealth drops significantly. They can’t get home-equity mortgages, for instance. At the same time, as housing prices fall, owners get deeper underwater and default looks more and more appealing. So while an individual default here and there does not affect society much, a rash of them does. Yet if you lighten too many mortgage burdens, as the Obama administration proposed to do, you lower income for the banks and make them less likely to lend. And that damage radiates, too.

Default Decisions

So what actually happened?

Intriguingly, despite the dire predictions, most underwater homeowners chose not to default. Recent research suggests that the reasons were mainly moral. Many homeowners apparently didn’t want the guilt and shame from skipping out on the deal. Perhaps, too, they didn’t want to hurt their neighbors by abandoning their current home and contributing to neighborhood blight.

At the same time, the federal aid programs had few takers. For instance, the Homeowner Affordability and Stability Plan, announced in February 2009, sought to help as many as 9 million homeowners to avoid foreclosure. However, far less than 10 percent have received any substantial relief, while about 4 million people lost their homes to foreclosure from 2007 to early 2012. And many of those losses have been processed improperly, in some cases fraudulently, to the banks’ advantage.

These foreclosure problems are doubtless due partly to the complexities higher up the food chain. But we share the opinion of many commentators that the larger problem is political. The financial industry spends more money on lobbying and campaign contributions than any other industry except health care, and it seems to get an excellent return on its investment. The industry opposed the mortgage-renegotiation programs, and then Treasury Secretary Timothy Geithner did little to get them off the ground.

(Daniel Friedman is a professor of economics at the University of California at Santa Cruz. Daniel McNeill is the author of “Fuzzy Logic.” This is the second of two excerpts from the second edition of their book “Morals and Markets: The Dangerous Balance,” to be published June 11 by Palgrave MacMillan.)

Editors: Mary Duenwald, David Henry.