No one knows for sure! One thing we do know is that depression is not a statement about your character. "Good" people do get depressed. Depression is not something that can be willed away, but it can be treated successfully. There are probably many interacting factors that produce depression. Here are some of them:
Brain chemistry: Bipolar disorder (manic-depression), in which a person's mood changes from irritability/sleeplessness/elation (mania) to depression, has been shown to be caused by biochemistry plus an environmental trigger (stress, substance abuse, sleep deprivation) which initiates the symptoms. As a chemical problem, it is best treated with a combination of specific psychiatric medications and supportive, directive psychotherapy. (People with bipolar depression who are simply given antidepressants for major depression or dysthymia can become manic.)
Some believe that people prone to major depression or dysthymia also suffer from a biochemical imbalance in their brains that is either present at birth, or triggered by an environmental event. In fact, although we know that depressed people's brains look and function differently under brain-scan imagery, we don't know which came first: the brain changes, or the depression! We also have ample research evidence for the ability of people to recover from depression using psychotherapy alone. If depression were purely a biochemical event, with no contribution from the environment, this would be impossible. In fact, a tendency toward depression seems to be partly inherited, but in many cases, one identical twin who is depressed will have an identical twin who never becomes depressed.
The connection between heredity and biology and depression is far from clear-cut, but it seems clear that some biochemical changes clearly accompany depression--primarily a reduction in the neurotransmitters serotonin, dopamine, and norepinephrine (the chemicals that carry nerve impulses across the gaps between nerve cells in the brain). Most antidepressants work by allowing your own neurotransmitters to 'repopulate' the gaps between your nerve cells instead of becoming trapped and unavailable for use as happens in depression. It is unlikely that depression is purely a biochemical problem, despite what the drug companies' advertisements may suggest.
Cognitive style: There is clear research evidence that a negative or pessimistic thinking style contributes to depression, and also seems to be a result of depression. Psychotherapy in which your pessimistic thoughts are carefully monitored, examined, questioned, and if necessary, changed, is very effective in lifting depression.
Loss, neglect, trauma: All of these experiences cause symptoms similar to those of depression. Trauma results in a feeling of powerlessness. A history of abuse in childhood accounts for 58% of all cases of depression, whereas only 10% of people with no history of abuse or neglect become depressed.
Family history of depression: Whether this risk factor is due to coping strategies you learn from your family of origin, or from genetics, is unclear. If you have a first degree relative with depression, you are at increased risk of depression.
Prolonged stress: Being exposed to long periods of stress during which you were unable to cope (because the stress was too great or because you didn't have the coping strategies or resources) can produce depression.
Drugs: Many drugs produce depression, including anti-anxiety drugs (Xanax, Valium), sleeping pills, steroids, antihypertensive drugs (clonidine, beta blockers), alcohol and other recreational drugs.
Sex hormones. Hormones can depress or elevate mood; fluctuating hormone levels tend to be associated with depression. Menopause rarely induces a first episode of depression.
Lack of light: Human beings were designed to receive 12 hours of light per day all year around. Most of us receive less than that, especially in the winter. (Sunglasses interfere with sunlight entering the retina.) People who are prone to depression are especially sensitive to light deprivation; foggy summer days in Santa Cruz can affect mood in that case.
Lack of exercise: Humans seem to need to move about 2 hours per day. Movement increases serotonin levels. (Walking for 1.5 hours doubles the serotonin levels in your brain.)
Sleep deprivation: Sleep is important for regulating neurotransmitters and your circadian (body) rhythm. Most people need at least 6 hours per night minimum (8 is ideal). (You may view tips for a good night's sleep here.)