Firstly, leverage. A lack of rules and enforcement allowed unreasonable amounts of capital to amass around mortgage bets. Without the crazy leverage via derivatives, the mortgage crisis would have been "A lot of loans go bad and some people get fired." Limit via regulation.
Secondly, capital requirements. My understanding is that mortgage-backed securities are treated preferentially in terms of where a bank legally can allocate capital. Consequently, as they had to find returns somewhere, they constantly needed to plow huge amounts of money into the market. Inflows of money >> smart money meant that price discovery broke down: those who cared were drowned out. You'd need to avoid structuring taxes, etc to artificially force capital into this scheme.
Hypothetically, there's no reason the US government couldn't structure its loan program thusly:
(A) Originate loans for existing fiscal year, (B) bundle multiple loans together / blind desired loan details (e.g. lendee race, etc), (C) auction off loans on the open market, (D) require budgeting for next fiscal year loan program on the basis of previous year's auction.
You'd get the benefit of price / cost discovery while controlling for unfairness as desired?
There'd need to be some legal papering to deal with the outcome lag, but it seems more responsive than the tossing money down a well we do now.