The plain answer is: AIG owed insurance payouts to many institutions that may have gone broke if they didn't receive them.
Governments generally don't think about whether a company deserves a bail out, but rather how strong the flow on effects would be if that company went under. And in the financial industry companies are so interlinked that the flow on effects of one going bust can be massive.
No companies that go bust deserve bail outs. It foster moral hazard. But if the whole financial system is at stake, I would prefer a company to be bailed out.