The end justifies the means
The idea is ancient, but it was not meant to justify unnecessary cruelty. It was part of a political philosophy called consequentialism. The basic idea is that a policy can be judged by its outcome. All modern versions of consequentialism have to deal with the limitations necessary to prevent tyrants abusing this idea.