I personally do believe that God may sometimes allow bad things to be visited upon us to teach us a lesson. Kinda like "You reap what you sow"
Also, refer to the book of Job:
...And the LORD said unto Satan, Whence comest thou? Then Satan answered the LORD, and said, From going to and fro in the earth, and from walking up and down in it.
And the LORD said unto Satan, Hast thou considered my servant Job, that there is none like him in the earth, a perfect and an upright man, one that feareth God, and escheweth evil?
Then Satan answered the LORD, and said, Doth Job fear God for nought?
Hast not thou made an hedge about him, and about his house, and about all that he hath on every side? thou hast blessed the work of his hands, and his substance is increased in the land.
But put forth thine hand now, and touch all that he hath, and he will curse thee to thy face.
And the LORD said unto Satan, Behold, all that he hath is in thy power; only upon himself put not forth thine hand. So Satan went forth from the presence of the LORD.