The government isn't *buying* Fannie and Freddie, so the cost won't be anywhere near five trillion. $200 billion, worst case. Not great, no, but less than 2 years worth of Iraq.
The reason why it had to be done, at least short-term, is that the only people able to get home loans now are prime borrowers, people with sterling credit, lots of assets, and cash in hand. Remove the security of Fannie and Freddie and there will be no money in the market available for anyone to get loans, and homes would basically become a cash-only purchase.
Now, that's not necessarily a problem, at least not for those who can purchase a home with cash, or who already own a home and who intend to stay there for a very long time. But anyone selling a home, welp, sorry, nobody can get a loan to buy it and few have that much cash. So, everyone goes to renting, and the number of unsold homes on the market grows and grows and grows, and the value of every home shrinks and shrinks and shrinks. Got $100k equity in a home now? Kill off Freddie and Fannie in this market and it'll be worth a third of that in a year, so your net value would take an enormous hit.
Absent Freddie and Fannie, the people who want to buy houses, that could afford the loan, still can't, because nobody's loaning. The people who own houses, their home value drops precipitously and whether they want to or not, they can't sell the house, at least not without taking a big loss (unless they bought it for $2500 in 1935 or something). Since everyone has to rent, rent prices increase -- supply and demand. So the result of the death of Fannie and Freddie would screw home buyers, home sellers, home owners, and renters. Which is, for all intents and purposes, everyone. The lending capability of Freddie and Fannie are all that is keeping the housing market going at all. Kill them, kill housing, at least for quite some time, several years at least.
I feel I'm fairly objective about this. Even if Freddie and Fannie are allowed to die, and the value of my home drops by 2/3, that won't really affect me. I don't plan on selling it for decades, if ever. I won't be upside down on the mortgage, no matter what happens. Since I don't plan on renting, I don't care if rent prices climb enormously. I don't care if I can't get a home loan, because I don't want to buy another home. I don't care if other people can't get home loans because I'm not trying to sell mine. So, I'm pretty objective, no vested interest in how this comes out. I am a compassionate person though. Most people are not in the situation I am in, which is absolutely ideal for enduring a complete market collapse, a new Depression; for their sakes, I hope Freddie and Fannie are kept alive in the short-term. Long-term, we need some economic thinkers to put their brains on this and see how to transition to something that will never again require costly government intervention, but that will still provide the liquidity 'grease' that the housing market must have to function and that currently only Freddie and Fannie are providing.
This isn't a problem that fits easily into a sound bite.