potentially nobody buys it. it's a loss.
let's say the smiths owe the bank 250k on a house they couldn't afford
then the smiths get foreclosed upon for non-payment.
the bank re-sell the house at say 120k, and takes a loss for the rest. they may sell their debt to other debt collectors/banks. but, suppose, the smiths don't pay them, anyway, or they move out of the country or whatever, then nobody will ever see that 250k.
multiply that to a larger degree and you see why the banks needed to go insolvent (or at least the insurance companies that backed the banks, needed to go insolvent, or both.)
the other banks that survive are the ones who did not over-speculate the real-estate bubble, had correct balance sheets, and had the foresight not to rest their entire existence on faulty insurance companies. Capitalism will keep the good banks in business and it will be a great lesson to the future banks.
the sooner we get all this illiquid debt out of the system, the sooner our economy gets working again.
so it's a actually a good thing -- just not to the banks.