Iyov believes in God, and believes that God is intentionally causing him to suffer, but he cannot figure out why. He is struggling to make sense of his suffering in terms of his relationship with and belief in God.
If he would commit suicide, he would be abdicating on that moral challenge, and "cheating" God, as it were.
When he tries to understand why God did not go all the way and kill him, and he expresses his wish that God would have done that, that opens new ways of thinking for him, allowing him to come to understand what God want from him, and why God pushed him almost to death and passed the point where he wished for death, but still kept him alive.