You are in very good company indeed in asking this question for the ages. For thousands of years humans have struggled with the question of why bad things happen to good people or why God seems to put humans to the test. If I had the answer to this question, I would surpass even Job in wisdom, for at the end of the book of Job even he admits that God’s wisdom is a mystery beyond human understanding.
In some ways the book is about Job being put to the test to see if he will remain faithful to God amidst his trials. Some people accept this as an adequate reason for their personal trials, even if they don’t blame God for bringing them trials, but rather accept them as a fact of life in a broken world. In this way of thinking, God isn’t the one who inflicts pain or trials on humanity, but suffers with us in our trials.
In other ways, though, the book is about Job putting God to the test and questioning God’s justice. It also questions the entire theology that a life of health and material blessings is a sign of God’s favor, while sins bring the curses of sickness and poverty. Jesus himself disputed this theology when he proclaimed that the man born blind was not born that way because of either his sins of the sins of his parents (Jn 9). Likewise, Job was right in insisting that it was not any personal sinfulness that was the hidden cause of his suffering. Ultimately, however, God refused to answer Job about why he had to suffer, instead giving him enough of a glimpse of God’s majesty that Job had to admit that his human understanding is dwarfed in comparison to God’s mystery and wisdom. It is an answer that isn’t an answer – it just brings us back to a sense of (healthy) humility that we cannot always find an intellectual answer for life’s most difficult existential questions.