# Why do suicide has been kept in natural selection? [duplicate]

Since I've heard about evolution theory, I tend to think about new things with the help of this theory. While not being always accurate, I find the reasoning that makes this theory possible very interesting.

We can ask a question like Why do humans have 2 eyes? and answer hypothetically that it was more advantageous for creatures to have 2 eyes than having 1 or 3. We can imagine that having 1 eye wouldn't allow to see the depth and make the creature able to live even when losing 1 eye. This answer isn't correct but makes sense.

We can do the same with behavior. Why do we tend to be jealous? We can imagine that forcing your sexual partner to stay with you gives your more chances to spread your genes. I'm not saying that this is the only answer but that's one hypothetical answer that makes sense.

However, what about suicide? From what I have read, people tend to suicide when their amount of pain is higher than what they can support. I don't see any reason why creatures(or anything from bacteria to human) would be advantaged from committing suicide. Why didn't the natural selection keep the individuals that can endure anything since they have more chances to stay alive and spread their genes?