Natural selection isn't necessarily preservational of individual genes (nor of genotypes). It just argues that the survivors are more genetically fit for survival. This aligns with GP's comment.
The Selfish Gene theory argues that behaviours among the group tend toward preservation of the genotype. Family over strangers, generally.
I do take issue with GP's "evolutionary purpose" -- these two words cannot be combined in a meaningful way. But, interpreted as "evolutionary contribution", it could make sense.
All that said, I also don't think that GP's idea floats, nor does it hold water. Genetic predisposition to depression is very poorly understood, but seems (to me) to be just ordinary phenotypical noise in the signal. Quasi-random variation which is to be expected in any sufficiently complicated system.
Think of the "freeze" response that, say, deer have when they get caught by a leopard. It would be best for the deer (and its family i.e. those with similar genes) if it didn't have a freeze response. It would be much better for them if they had a "fight till death" response. That way, every time a leopard caught a deer, it would get most likely get injured and leopards would be able to hunt fewer deer.
The deer has a freeze response because it has nothing to do with what's good for the deer and everything to do with what is good for the ecosystem. It's best if it outruns the leopard... but if it gets caught, it's best if it freezes while the leopard kills it.
P.S. The mainstream explanation of the freeze response is that "it helps the deer deal with the pain". However, they fail to explain what the evolutionary benefit to not feeling pain as one is being eaten is.
No, they don't. That's simply wrong. They favor their own survival.
And you really didn't need to post this twice.
I have no idea if it applies to depression. I don’t really buy the simple story from GP.