Goldman had CDS against AIG imploding, had CDS-of-CDS against AIG's counterparties imploding, etc., etc. The solution to this hedging problem turns out to be the eigenvector of a CDS/exposure matrix, which is kind of fun.
Anyway... Goldman's bet was that the whole world would not implode. If there had been no bailout of anyone--you're right--everyone would've failed, including Goldman. In this scenario, there's no doubt in my mind unemployment would be higher today. But, given that someone was saved--anyone at all--Goldman turned out just fine. The cost of this hedge was ~$2.5 billion. For this, they were able to recover $10 billion. So, 75 cents on the dollar. More than they deserve!
The real crime has nothing to do with "needing to be bailed out"--this is just the story given to the public--it's the fact that Goldman may have had material nonpublic information about AIG. I think this article sums it up pretty well:
http://www.realclearmarkets.com/articles/2010/01/13/goldman_...