For those who believe in God

I've been to Catholic school from kindergarten to 12th grade and I never cared for religion until about 2 years ago when I turned 25. I went off to basic military training and God was pretty much all I could turn to while there. My question is, if there is a God, why do bad things happen to good people? Why do innocent good people get killed? I'm absolutely very blessed in life and I believe it's God who put me in that situation. But if something really bad happens like something to my child or husband, how can you believe in God still?