A lot of salesmen sold mortgages that they knew were bad, to people they knew would probably not be able to pay them off. They did this because they got a commission and fees off every mortgage they sold, but none off those they declined.
Banks both federal and private made the bad loans because they could then sell them to investors, and so would not get stuck holding the loan if it defaulted.
They were able to sell the bad mortgages to investors, first, by bundling them into huge CDOs with thousands of loans, bad and good, so investors had a hard time figuring out that many of them were bad. They figured bundling them together made the package stronger. Actually it meant that if some of them failed, the whole package would collapse. Second, the banks got the rating agencies to rate the CDOs triple A, so they would look good to investors.
The rating agencies rated them AAA because they got paid to. They were paid, a lot, not to rate or evaluate the investment, but for giving them AAA. If they did not, the banks could go to another agency which would cooperate.
These were cheap adjustable rate mortgages, so as soon as the rates went up, the home owners, who could barely or not at at all afford them anyway, defaulted.
The banks and investment companies went bankrupt. Many had bought the CDOs themselves! A good con artist believes his own con.
The federal government, Republican and Democratic, bailed out the banks, except Bear Stearns. The other alternative was to let the financial system collapse into another world depression, like in 1930. The banks were too big to fail, too big to jail, which was another reason the didn't hesitate to make bad loans.
The banks took the billions from the government and used it partly to award bankers with huge bonuses, in the hundreds of millions. From the bankers' point of view, they could tell their stockholders that they had gotten billions of free money from the government, saving the bank, so they deserved a big bonus.
The good news now is that the economy finally recovered and the banks paid back the fed, so the taxpayers got their money back. The bad news is nothing has changed. Those wonky financial instruments, like CDOs, are still around, the banks are bigger than ever, and not one single person went to jail. Some investors tried to sue the rating agencies for fraud, but were laughed out of court.