I believe that god allows bad things to happen, only for the purpose of our good. The Bible tells us to rejoice in trials because of the benefits that they result in.
Some bad things test us, and these tests either strengthen us or show us the areas that we need to work on (with God's help!). If we truly pass the test then it is rae for us to have to go through that same test again. If we do find ourselves in a similar position later on, the likelihood is that we didn't pass the test in the way that God expected us to.
Some bad things happen because, in the end, it will lead to God being given glory. Consider the bad things that happen in the lives of unbelievers that, in the end, lead them to call on god to rescue them, and bring them into salvation. Sometimes this happens in the life of a believer who perhaps needs to rethink his/her walk with God.
consider also Pharoe, who was put on the earth with the sole purpose of causing the Israelites grief, so that God would be able to rescue the Israelites and have that glory, even thousands of years later. And we are still able to learn from all the bad things that the Israelites went through!
But bad things also happen because we live in a world full of sin and free will, where satan dwells and reigns (for now). So sometimes it is simply a case of 'that's life'.
Finally, i believe that we often think things are bad when they are not so bad. I thought it was bad when my grandma died, but she is with God, which is anything but bad. I thought it was bad when my boiler broke and I had no heat or hot water, until I realised how blessed I am to have a roof over my head and water to drink. Now i rejoice in my broken boiler because it is teaching me not to be so spoilt, and to care more about those who go without these things on a long-term basis.
To summarise, I believe that sometimes God makes things happen that we consider to be bad, but God knows that they will be for our good in the long-run.
I also believe that God allows bad things to happen, to give us the opportunity to respond well, and thus grow spiritually; or if we don't respond well, then to learn from it for the next time we have to go through it.
and then there are the things that just happen because there is sin and free will in the world, so we just have to brush ourselves off and pray for the strength and perseverence to deal with those things that are 'just life'.