The end justifies the means

The end justifies the means is a phrase of Niccolò Machiavelli. It means that if a goal is morally important enough, any method of getting it is acceptable.
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.