Or at least they earned what they got.
Time was, when banks couldn't write mortgages fast enough. And not "good" mortgages, but more like "random" mortgages. Basically without regard to quality.
Sloppy underwriting (of the credits) was accompanied by sloppy writing (of the documents). Banks basically didn't build any default protection into their lending process. Because home prices would only go up. And borrowers would refinance (presumably with someone else). And loans could be packaged and resold to investors. Basically, banks were taking "no risk."
Except that they were. We've found out in the past two years that home prices can go down as well as up. Meaning that not all loans could be sold. And some of the earlier loan buyers were either smart enough to insert "put" clauses into contracts, forcing banks to take back the loans if defautls reached a certain level, or are going to courts, alleging "misrepresentation," which might have the same effect.
Somebody has to "eat" the bad loans. And that somebody, nowadays, is the lending bank.
When your main function in life is to underwrite junk, not because you want to own it, but just to shove it out the door, you stand to get bitten. And from both ends.