When the stock market does well, market participants become confident and start borrowing money to invest, thinking they can do no wrong. This inflates the market to the upside. When the market falls, margin calls force these borrowers to sell their shares to pay off these debts, which helps create a market environment where some great companies sell for less than what they're worth.
We can see the rise and fall of margin levels on the NYSE through the last recession in 2001 (source: NYSEData.com):
We can see that it takes some time for margin money to return to the market. Certainly, much of the money being pulled out of the market now is related to margin debt. Here's a look at the latest data through August:
We should expect to see September and October margin continue to even lower levels as speculators leave the market.
When speculators are forced to sell their stocks due to their over-leverage, it creates great opportunities for long-term investors, as companies like these go on sale!