I'm not sure that there is any conscious purpose behind our ability to willingly self-destruct. It is maybe just a by-product of the evolution of consciousness to the point of self-consciousness, as with humans and possibly a few other animals.
I mean, when you have a being with a sense of self, self-awareness and also awareness of its own death, that it will die at some point in the future, like humans, then intentionally causing the death of the self will naturally arise as a possibility.
Then again, some insects will actually commit suicide, but only to protect the colony, and it is probably only an instinct with no real awareness behind it. "Some species of social insects will commit suicide in an act of altruism through autothysis. These insects will sacrifice themselves if the colony is in danger, to alert the colony of danger, or if they become diseased they will sacrifice themselves to prevent the colony from becoming diseased. " (Wikipedia article on animal suicide).
So maybe suicide in humans is just a very refined and sublimated form of insect self destruction. It is nature's way of 'protecting' the human gene pool or something.