Part-time Pizza Cat
Take what I say here with a grain of salt as evolutionary psychology has some, rough edges.
Firstly, from a purely genetic perspective, several genes that play a role in the likelihood of developing depression also seem to be at least partially linked to stronger immune responses.
In this respect, depression is more of an unfortunate side effect of an evolutionarily advantageous genetic quirk.
Psychologically, there has been some evidence that depression makes people ruminate more. And that those who are more prone to deep rumination are natural problem solvers and better and thinking their way out of a dangerous situation. It’s also believed that the boredom and listlessness of depression and ADHD may have led to large scale human migrations.
Again, take all that with some grains. Levels of evidence vary, the former having more basis in genetic science than the latter, and there are a couple other theories. Those are just the few I know off the top of my head.
Also, you’re smarter than you think simply on the basis of a willingness to learn. Unlike some of the folks around here that are so mired in their own little piles.