If we accept the ideas of evolution and natural selection, then we must also accept its unguided purposelessness. The fact that an organism is "capable of" depression does not imply that depression has any use or purpose. It just means that the physical processes of that organism, which have on the whole performed well, can produce depression.
The genetic mechanisms that underlie evolution have a great capability to isolate and treat as independent the different aspects of an organism to be selected for or against. But we must remember that despite this capability, there may be traits that are practically inseparable in their expression in the organism, because these different traits actually arise from the same mechanism. It would make no difference if such traits, inextricably linked, were to differ from each other in their ability to contribute to survival value. Only the sum total of their contribution to survival value would matter.
Asking whether depression has survival value is like asking whether car exhaust serves car manufacturers in any way. Car exhaust is a byproduct of internal combustion engines, which themselves have dominance for historical reasons and because of their power and performance. There is no way to change an internal combustion engine in a small way so as to eliminate car exhaust. Car manufacturers keep making cars that make exhaust because those cars, despite their exhaust, continue to sell well. The trait of exhaust, inextricably linked to the trait of performance as found in the internal combustion engine, cannot be independently selected for or against.
Depression is a byproduct of the current evolutionary configuration of human brains, which themselves have dominance for historical reasons and because of their power and performance. There may very well be no way to change the human brain in a small way so as to eliminate the possibility of depression. Evolution has allowed depression as a trait to continue because humans, despite having possibly depressed brains, continue to reproduce and survive. The possibility of developing depression, potentially inextricably linked to the specific aspects of current human brains that give them their high performance, could not then be selected for or against independently of those aspects.