It is the universal experience of mankind that, sometimes, things turn out lousy.
Faced with this prospect, we turn to our practical reason in order to devise means by which things might turn out copacetic. Sometimes, though, the best we can do is devise means by which things might turn out slightly less lousy than they would have anyway.
As St. Thomas explains, the first precept of the natural law, from which the practical reason derives human law, is "good is to be done and pursued, and evil is to be avoided." When practical reason is working properly, then, it will avoid proposing evil means, even when evil means are the only means to a copacetic end.
All that said, there's still something attractive about the idea that a copacetic end is always morally achievable. It's a special case of the ends justifying the means, where the appeal is made, not so much to the copacetic end the means would achieve, but to the lousy end that will occur without those means. And it's not an explicit, "These bad means become good since we're using them to achieve this end," but more like, "These ends must be good! Just look at what the end will be if we don't employ them!"
Alas, the natural law is not suspended in case of emergency.