The question posed was why do Bad things happen to good people? You noted that, from I assume a scientific perspective, bad things are just often random occurrences that people artifically label as "bad." My response is that Bad things are not random and result from a deviation from the natural order and that our sense of that wrongness from those deviations is not supernatural.
To put it in a more realistic scenario (I only used torture previously because even non-human species have been shown to avoid and punish torture). Let's say I begin to suffer from chronic dehabilitating headaches and these headaches force me to stop doing the charity work I have done all my life and I become depressed to the point of contemplating suicide. I have no family history, genetic disposition, history of drug abuse etc. What I did do was build a house in 2002 that used imported drywall from China containing volatile chemicals that have been emitting sulfurous gases, carbon disulfide, carbonyl sulfide, and hydrogen sulfide which have been absorbed into my body altering my chemical makeup ever since.
Is it by a random path that those molecules found their way into my body? Or is it a result of the actions of people disregarding their sense of wrongness? Yes. Am I also free from fault? No. Because I am part of and have benefitted directly from a culture that values paying the least at any cost and doesn't properly price environmental damage/costs into the marketplace. I could have built my house smaller for example paying a higher price for building materials.
I could speak to your other example of discrimination by sexual orientation in the context of natural law, but I would face immediate downvotes and this isn't really the place for that discussion.
We will just have to agree to disagree that human ethics hasn't really progressed that much in the last few thousand years. Natural law persists but what humans value obviously alters over time. That is, how strictly a culture decides to punish acts of torture of animals is a reflection of the culture, not evidence of its wrongness or the nature of the act. Personally, I believe that the slower rate of progress in removing Bad things from happening is largely that say unlike physics or chemistry, there is no way to improve the pedagogy of morality. With the introduction of mathematics and the creation of a universal language for scientific understanding progress at a remarkably faster rate was achieved in the last few hundred years because it is easily transmitted between generations. The only way moral education is imparted from generation to generation is by example. You can't educate morality beyond telling stories and parables and living by example so positive changes more in accord with natural order are limited in scope by time and geography.
I think if you surveyed those people who justify torture in our time if torturing their children was wrong, you would find overwhelmingly that that they would say it was, but that they believe they have a right or should be able to do it to "others" based on some circumstance (such as they did some other Bad act). Doesn't mean they know that the act of torture is any less contrary to the natural order or that it won't have consequences as a result, just that they are choosing to value something else greater (and, wrongly I might add). Similarly if you asked someone eating an omelette how it tasted before and after you gave them the experience of the conditions in a factory chicken farm, you would generally get a very different response. It has been shown actually to alter the perception of the taste of food in subjects and induces disgust, that is how tuned to the natural order humans are.