WASHINGTON (CNNMoney.com) -- So how did it come to this? How did American International Group go from insurance giant to national outcast?

While the government is propping up dozens of companies left teetering from one of the worst recessions in decades, AIG has emerged as the most reviled by far.

It wasn't always that way for AIG -- once revered and even feared as the world's largest insurance company.

But that was before AIG sucked up $170 billion worth of taxpayer dollars and doled out millions in bonuses to some of the very employees responsible for its own demise.

The Obama administration doesn't like the bonuses and says it will move to recoup $165 million in tax dollars used to pay them. Senate Democrats are pushing proposals to drop a heavy tax on the executive payments, many of which topped $1 million.

"AIG's attitude represents everything that's wrong with Wall Street -- greed and perhaps even corruption," said Senate Majority Leader Harry Reid, D-Nev.

The controversy went before a key House panel on Wednesday. AIG Chief Executive Edward Liddy, who took office in September after the government stepped in, was set to face tough questions -- questions about the bonuses, the bailout and the future of the company that has become public enemy no. 1.

Birth of a bailout

AIG insured everything from life to cars and homes. It had $1 trillion in assets, $110 billion in revenue and 74 million customers. The trouble started with a London-based subsidiary called AIG Financial Products that worked on deals that looked and acted like insurance, but wasn't considered insurance.

During the real estate boom, investment firms were buying and selling securities backed by pieces of mortgages. The firms paid AIG Financial Products to back up the investments. If the investments turned south, AIG promised to make up the difference.

The entire system was based on the assumption that everything wouldn't go bad at the same time.

AIG was selling what are known as credit default swaps. While credit default swaps sound like insurance, they didn't have to be watched by the government in the way that insurance does.

"They were selling an insurance type product that isn't called insurance so it wasn't regulated like insurance," Andrew Barile, a California insurance consultant. "By calling it a credit default swap, you have invented a new product, but it's no different than insurance."

Guess what? The worst case scenario happened and many of the investments did go bad with the collapse of the real estate market. Suddenly, AIG didn't have enough money to pay back all the promises it had made to back up all the investments.

The government -- the Bush administration and Federal Reserve -- decided to step in with the bailout last September. AIG had gotten tangled up with many banks and investment firms across the globe. If AIG didn't pay up, the global financial system might have collapsed, policymakers said.

AIG, under pressure from officials, only recently revealed to the public that it had passed on billions of dollars in federal money to investment firms like Goldman Sachs (GS, Fortune 500) and Merrill Lynch that had bought the financial backup policies.

All told, the government has poured $170 billion into the AIG (AIG, Fortune 500) bailout.

From the beginning, the point was to keep AIG out of bankruptcy and afloat long enough so its dangerous financial bets could be unwound and its valuable units sold off to raise cash to pay back Uncle Sam.

What the bonus controversy is really about

Last Friday, AIG paid out about $165 million in bonus checks to employees who worked in the troubled AIG Financial Products unit. The bonuses were part of a larger package, some $450 million due to these employees in 2008-2009.

New York state Attorney General Andrew Cuomo on Tuesday said that 73 employees got more than $1 million each, including 11 people who don't even work for AIG anymore.

President Obama says he wants to try to get the bonus money back. Turns out, it can't be done so easily.

Treasury chief Tim Geithner says he found out about the bonuses last week, although AIG revealed in regulatory filings last year that it was giving such bonuses. The contracts had been set up months before the government became a nearly 80% owner in the company. Treasury's lawyers said it would be legally difficult to block the bonuses.

The best Treasury said it could do right now is to ensure that the public coffers get reimbursed for all the bonuses on top of all the other money AIG owes. Treasury says it will add a reimbursement provision to latest deal to pump another $30 billion into AIG.

In the meantime, Congress is itching to get involved. Senate Democrats are talking about legislation to tax the heck out of the bonuses. Two key senators on Tuesday said they would try to impose a big tax on retention bonuses paid to executives of companies that received bailout money or in which the United States has an equity interest.

Next steps

The government's endgame is to keep AIG's troubles from further damaging the markets and to get its money back. Many questions remain about the future of the company and the government's role as part-owner, part-watchdog, part-sugar daddy.

For now at least, the bonus controversy is stealing the show. AIG executive Liddy is expected to get an earful on the topic when he goes before the House Financial Services subcommittee on Wednesday.

But Liddy will also talk about his efforts to make sure the government gets its money back. AIG is working to unravel its credit default swaps. And the company has valuable subsidiaries that could be sold. That's certainly what the government hopes. It has $170 billion so far riding on it.