"And we know that God causes all things to work together for good to those who love God, to those who are called according to His purpose." Romans 8:28
Some people believe the Bible teaches that all things work together for good for everyone, but it’s not true.
What the Bible does teach is that all things can work together for good for those who love God and are living in His will. We have to love God through Jesus Christ and live according to His teaching in Scripture. To believe anything or to live any way we want nullifies the truth of this verse.
But when we love God and are living for Him, then with any tragedy, any suffering, God can bring good. For with every tragedy and every setback, our choice is to grow bitter or to trust God to bring good out of the greatest grief and difficulty. Even when life doesn't make sense. Look for the good that God can bring.