Catholic theology relating to suicide generally flows something like this:
Murder is sinful; suicide is a form of murder in which the murderer and the victim are the same person.
The “wrong” at issue with suicide is the sin of despair. Despair is the opposite of hope; in fact, it actively denies hope (as in, “You have so much to live for!” “No, I don’t.” “Things will get better!” “I don’t think so”). At its peak, despair actively challenges God’s power and forgiveness; eventually, if the person persists in despair, he or she will begin to feel that not even God cares, and not even God can do anything to help. This is a rejection of God at the most fundamental level.
Despair is not the same as depression. They sound similar, and there is some overlap, but they are not the same. Depression is a mental state that can cause its sufferer to stop caring about life or even actively seek death; despair is a spiritual state that can cause its sufferer to stop caring about life everlasting or even actively seek spiritual death. Despair is a sin; depression is not. They can feed on each other, but they are different things; in fact, depression, like any other mental illness, can mitigate the sufferer’s culpability for despair.
The reason Jesus spoke of the unforgiveable sin (blaspheming the Holy Spirit) is not that God wishes to protect the Holy Spirit from slander or any such nonsense. In the Gospel text, the pharisees and scribes were challenging Jesus’ miracles, saying that He was expelling demons through the devil’s power; in other words, they were witnessing the power of the Holy Spirit but refusing to believe in it, preferring to ascribe God’s actions to evil. Jesus was merely pointing out that a person who refuses to believe in the saving grace of God cannot receive it. The scribes and Pharisees were being obstinate in their disbelief of Jesus and His message; that obstinacy – that sheer refusal to accept God’s grace in the light of overwhelming evidence in support of God – is a self-fulfilling prophecy that prevents the sinner from accepting God’s grace. Blaspheming the Holy Spirit isn’t a crime that results in a punishment of unforgiveness; it’s a decision by the sinner not to accept forgiveness.
Suicide can be like that: killing oneself is often the ultimate act of denial of God’s grace. That’s why it is gravely immoral; it is a fundamental rejection of God and, in many cases, it is a specific decision to do so.
But we trust in God’s mercy and forgiveness. We know that He is perfect and all-knowing. We have free will, and He will not interfere with that; but He knows what we suffer, and He is perfectly capable of offering solace and mercy to those who have killed themselves. The Church teaches quite clearly that, although no one should commit suicide, we may pray for those who have done so, and we should not despair over their fates.