Sometimes it is judgement. Sometimes it's because people need to turn to Him and don't do so until they need Him. He may have purposes other than those. I don't know why and neither does anyone else.
Bad things happen to good people but as I said, there's a purpose and God is in control. You are not and neither am I.
People here are judging the residents of this town which was just burned to the ground and I need to be careful?
You need Jesus.