Normally depression is seen as a negative side effect of emotional trauma, abuse or some random physiological or medical factor. Depression is not seen as something functional or meaningful per se.
However, I have seen research that tries to explain depression as an attempt to achieve the social isolation needed for healing and recalibration.
Think of it this way: We are all born with a need for self expression and self realization, which may lead to conflict with others. Good parents and good friends give people room to explore and express themselves (within reason).