Good and bad are judgments based on our evolutionary goal of survival eventually culminating in some idea of society. Lots of these ideas often become contradictory in the end as morality is to organize society and their are more effective and ineffective strategies to that end. To prevent bad things, make things predictable, that others can be relied on, and so on. But there is no omnipresent law, akin to say math platonism, or the physical laws of our universe. So it doesn't make much sense for an actor in a society to say it might be moral to end the society/species as it's ignoring the purpose of that "morality" in the first place. It is "detached" needing to be based on other "axioms", say "that every rock is sacred". But these are no more universally valid despite people's hope for a ethical platonism, and are potentially an inferior choice for the only objective that matters, continuation of the system (spieces/individual/etc).
In your example, optimizing at all cost to remove suffering ignores that suffering and pain are part of the process of warning in survival and are an inferior objective in the overall goal of survival. Sure you can choose it at all cost, but it's a poor strategy. A greedy algorithm as it were.
To be forthright and to illustrate this line of thought, I responded to you in the hopes that you will understand part of this, and continue to live and keep this system going, as it appears to be a better overall strategy to continue society. Not morality but "strategy". And frankly, from personal preference, it's more interesting than some inky blackness with nothing to do.
You do hit on a point that's often overlooked that a lot of designs of morality start to break down at large timescales of a couple generations. For example, arguing that a bad action in the past seems a bit poor for oneself if it results in the person not existing. How about the countless others that would exists on just minor variations of that history?
Anyway, try to challenge your initial thoughts and see if you come to this or something else. And keep thinking about moral systems at timescales as it's interesting to think about.