But as for you, you meant evil against me; but God meant it for good, in order to bring it about as it is this day, to save many people alive.
Genesis 50:20
When something bad happens in the life of a new Christian, they will often say, "Lord, why is this happening to me?" When something bad happens in the life of a mature Christian, they will often say, "Lord, why is this happening to me?" Same question, but different motivations. The new Christian may think it unreasonable that a bad thing happened. But the mature Christian knows problems are part of life in a fallen world. His "Why?" question is to discern from God what he can learn from the difficult situation—how he might grow in faith.
Recommended Reading:
Romans 8: 28 – 29
When the teenage Joseph was sold by his brothers into slavery, he no doubt asked the "Why?" question. At first, he may have thought, "What did I do to deserve this?" But later, his "Why?" likely turned into, "Oh, now I see why!" He realized God had sent him to Egypt to prepare a place for Jacob's family to escape the famine in Canaan.
When you experience difficulties in life, it's not wrong to ask "Why?" Just make sure you're asking for the right reason.