the loans they "gave" out were predatory as fuck, ARMs with balloon payments. these were extremely profitable loans and the banks over leveraged themselves to chase them and sign up as many as they could with shit like "Ninja" loans (no income, no job). the nut on those loans was insane for the lender and they would turn around and sell them to investors for big bucks after rating them as AAA safe. you have to remember banks are inverted. banks see savings accounts as liabilities and loans as assets. savings accounts cost them money and loans make them money.
loaning money to people who have shit credit and no collateral is far more profitable than the terms a lender can get loaning money to rich people with assets.
The Big Short is an entertaining movie that is also educational as hell about what happened, from a technical perspective.
the legacy of the GFC in the US for mortgage lenders is PMI aka Personal Mortgage Insurance. this is a mandated insurance premium the borrower has to pay on top of principal+interest payments on a loan that is "riskier". that's right, the insurance on a riskier loan is paid for by the borrower, but the lender is the beneficiary if the borrower defaults.
it's a beautiful system for capital formations.