https://www.gotquestions.org/question-God.html
Question: "Is it wrong to question God?"
Answer: At issue is not whether we should question God, but in what manner—and for what reason—we question Him. To question God is not in itself wrong. The prophet Habakkuk had questions for God concerning the timing and agency of the Lord’s plan. Habakkuk, rather than being rebuked for his questions, is patiently answered, and the prophet ends his book with a song of praise to the Lord. Many questions are put to God in the Psalms (Psalms 10, 44, 74, 77). These are the cries of the persecuted who are desperate for God’s intervention and salvation. Although God does not always answer our questions in the way we want, we conclude from these passages that a sincere question from an earnest heart is welcomed by God.
Insincere questions, or questions from a hypocritical heart, are a different matter. “And without faith it is impossible to please God, because anyone who comes to him must believe that he exists and that he rewards those who earnestly seek him” (Hebrews 11:6). After King Saul had disobeyed God, his questions went unanswered (1 Samuel 28:6). It is entirely different to wonder why God allowed a certain event than it is to directly question God's goodness. Having doubts is different from questioning God's sovereignty and attacking His character. In short, an honest question is not a sin, but a bitter, untrusting, or rebellious heart is. God is not intimidated by questions. God invites us to enjoy close fellowship with Him. When we “question God,” it should be from a humble spirit and open mind. We can question God, but we should not expect an answer unless we are genuinely interested in His answer. God knows our hearts, and knows whether we are genuinely seeking Him to enlighten us. Our heart attitude is what determines whether it is right or wrong to question God."