[I]n most instances, depression should not be thought of as a disorder at all. In an article recently published in Psychological Review, we argue that depression is in fact an adaptation, a state of mind which brings real costs, but also brings real benefits.
...
So what could be so useful about depression? Depressed people often think intensely about their problems. These thoughts are called ruminations; they are persistent and depressed people have difficulty thinking about anything else. Numerous studies have also shown that this thinking style is often highly analytical. They dwell on a complex problem, breaking it down into smaller components, which are considered one at a time.
...
Indeed, when you are faced with a difficult problem, such as a math problem, feeling depressed is often a useful response that may help you analyze and solve it. For instance, in some of our research, we have found evidence that people who get more depressed while they are working on complex problems in an intelligence test tend to score higher on the test.
...
But is there any evidence that depression is useful in analyzing complex problems? For one thing, if depressive rumination were harmful, as most clinicians and researchers assume, then bouts of depression should be slower to resolve when people are given interventions that encourage rumination, such as having them write about their strongest thoughts and feelings. However, the opposite appears to be true. Several studies have found that expressive writing promotes quicker resolution of depression, and they suggest that this is because depressed people gain insight into their problems.
1. "Depression's Evolutionary Roots: Two scientists suggest that depression is not a malfunction, but a mental adaptation that brings certain cognitive advantages" by Paul W. Andrews and J. Anderson Thomson Jr.