i see no problem in buying a foreclosure. many homeowners that have been foreclosed upon have been living in their house essentially rent free for multiple months (in some cases, up to a year) as they haven't made payments, and although they might be getting screwed by the banks, banks often try to meet homeowners at least part of the way, since the bank will usually be taking an even larger loss on the loan if it is foreclosed upon.
also, although i don't believe this was the case for most homebuyers, some homebuyers did understand the risk of purchasing an expensive (for their means) home, and made the judgment that they'd be able to pay for their loan. just because some bought more than they could afford, you have no personal liability in that. it's likely that your taxes are already paying for their loan, after all.
unfortunately, however, most people weren't in that boat. i recommend the book The Two-Income Trap: Why Middle-Class Mothers and Fathers Are Going Broke by Elizabeth Warren and Amelia Tyagi for more information about lending practices by banks, and what you can do to help change the current situation.
the one ramification that is very clear is that the house may be torn up before the current squatters leave. i agree with matt from denver in that you should find an experienced inspector before finalizing your loan.
good luck and happy house hunting!