GM was illiquid due to the 2008 financial crisis, that set off a downward spiral of cash flow.
Letting GM die would have had massive systemic effects on the economy: suppliers and dependent businesses would have also gone bankrupt, and an estimated half million people would have been out of work. The combined lost GDP and higher unemployment, would have led to a much more severe downturn and a much higher federal deficit than the $10b lost on the bailout due to the automatic stabilizers for UI, food stamps, and medicaid, along with the reduced taxation revenue of individuals.
None of this would have made sense of GM were not a going concern (i.e. it couldn't make money anymore). Clearly it could, but it had massive issues that made it fragile. Now it is less fragile.
The government probably could have tried to hold onto some of the 60% of shares it owned for a profit, but politically, unlike Canadians or Europeans, a partially nationalized firm is not something Americans enjoy ("Government Motors"), so it made sense to take a loss early to save the political face.
My point was that they weren't necessarily "this company should be liquidated" problems, they were "this company needs to restructure its debt obligations and rethink its strategy" problems.
GM retains its position as the world's #2 car maker by volume, behind Toyota, and is profitable again. It's going to die some day, but probably has a lot of life (and thus economic contribution) left in it. Sometimes governments step in to prevent the "creative destruction" of the market to destroy its own citizenry. The open question is where the limit should be.
The modern GM that survived has only superficial resemblance to the GM of old, which not only had 50% domestic auto marketshare, but also built everything from trains to refrigerators to satellites. The company that went bankrupt was the one left holding the "legacy costs" bag.
Don't forget they bought Saab and basically ruined the brand within a couple of years with poor quality and no innovation.