In a macroeconomic sense, recessions aren't bad things; they're adjustments. In a broad sense, they result when inventories have built up to the point that production has to decrease until the inventories come down to a reasonable level. The problem is that when production declines, then demand declines, and then it takes longer to reduce the inventories. When there are rising prices on, say, corn, farmers readjust their capacity to grow more corn. Over time, the supply and demand balance shift, but people who have grown corn with certain price expectations are reluctant to take losses. Especially when the incremental capacity comes at higher average fixed cost. Prices will eventually go down, but some of the capacity will have to be shut down and investments written off. Social costs follow, with dislocated farmers and farm workers.
In this particular case, a bunch of people assumed that residential real estate prices would continue to rise and markets remain liquid, thereby assuring value of the collateral of loans made to people who might otherwise default. Investors underestimated the risk of the assets and priced them incorrectly.