The O.C. explains that Hashem has complete control over animals and everything else in the natural world. If Yosef didn’t deserve to die, the snakes and scorpions would not be able to harm him. It was the perfect test to see if the brothers were misjudging Yosef or whether he really was guilty. However, a human being is different because he/she is a “ba’al bechira.” Hashem does not interfere with free choice. Had Yosef been turned over to the brothers or other people, even if he didn’t deserve to die, they would still have been able to harm him had they chosen to do so.For better or worse, most kids, like my daughter, come out of yeshiva thinking about hashgacha along the lines of the Chovos haLevavos, who assumes that nothing can happen unless Hashem decrees it so. Person X can pull a gun on person Y and pull the trigger, but unless Hashem has decreed that person Y will come to harm, nothing will happen to him. On the one hand, it seems “frummer” to assume there are no exceptions to Hashem’s hashgacha, but on the other hand, if you take this approach it means there is no such thing as random violence and anyone who is harmed must have deserved it. Seems to me that the question of theodicy is no less difficult than the issue of hashgacha. In any case, if you’ve been taught or absorbed through osmosis that the Chovos haLevavos is correct, then this Ohr haChaim is not going to be easy to swallow.
R’ Elchanan Wasserman (Koveitz He’Oros) claims that other Rishonim (e.g. Tosfos Kesubos 30) disagree with the Chovos haLevavos, and the Zohar does as well, so the Ohr haChaim’s view is not unique. According to R’ Elchanan, we are left with a basic machlokes about the scope of hashgacha. The Lubavitcher Rebbe, however, tries to reconcile the two views (link). By way of analogy, he compares dealing with a ba’al bechira to the gemara’s caution not to stand in a dangerous place. Why can’t a person try to walk a tightrope over the Grand Canyon or do some other dangerous stunt? M’mah nafshach: if he/she is destined to come to harm, then he/she will come to harm whether he/she goes on the tightrope or not; if he/she is not destined to come to harm, then there is no danger! The answer is that whether or not a person will come to harm is not an absolute yes/no issue – it’s a matter of degree. A person may have enough merit to warrant not coming to harm in the normal course of events, but that same person may not have sufficient merit to cause Hashem to change the laws of nature and allow him/her to survive a fall into the Grand Canyon. It’s not Hashem’s hasgacha which makes the difference between the cases – it’s the person’s merits which make the difference. What the Zohar/O.C./Tosfos may be saying is that to survive an encounter with a “ba’al bechira” requires much greater zechuyos, as it requires Hashem interfering with the laws of nature (that allows for free will) much more openly. Therefore, it is far better to face a threat from an animal or an object.