You’re at the park. Your dad tells you that you can play on anything except the monkey bars, because you’re not old enough and he knows you’ll fall off and hurt yourself. Just when you think your Dad’s not looking, you mosey over to the monkey bars and climb on. Before you hit the first rung, you fall. Your dad quickly steps in and catches you. The next day you go back to the park. Dad says you can play on anything but the monkey bars because you’ll fall and hurt yourself. You quickly run for the monkey bars, get half way up and fall. Your dad sees you fall and steps in to catch you. This happens repeatedly; you’re told not to play on the monkey bars because you’ll get hurt, you play on the monkey bars, fall and your dad catches you. Until one day, you climb on the monkey bars and this time, your dad lets you fall. You hit the ground and it hurts, BAD. You question your dad, “Why did you hurt me?”…
We do this with God too. He warns us of dangers to protect us, but we do what we want anyway and then we get mad at HIM when we get hurt. It’s like some people use the protection of God to justify their disobedience. Proverbs 19:3 “People ruin their lives by their own foolishness then get angry at God when they get hurt.” God’s instructions aren't to punish us; they are for our own good, to protect us. We often wonder why God lets things happen, why God would allow pain or death. What we fail to remember is that each person has their own free will to choose whether or not they listen to his voice. But for some people, it’s easier to be mad at God, rather than accept that truth.
Next, you might be asking “What if something happens that wasn't because of someone’s choice or behavior etc?” Example: A poisonous snake bit you when you fell off the monkey bars, you were poisoned and died. God didn't have anything to do with that poisonous snake, but he DID warn you multiple times not to climb the monkey bars in the first place. Not only did he know you’d get hurt by falling off, he knew the snake would be there. That snake was your adversary, Satan, who walks about like a roaring lion, seeking whom he may devour (1 Peter 5:8).
How did the Lord warn you? He warned you through your dad, by having him tell you not to play on the monkey bars, but you didn't listen.
Resources: Why Do Bad Things Happen to Good People?