the end justifies the means
Definition from Wiktionary, the free dictionary
Alternative forms 
- Morally wrong actions are sometimes necessary to achieve morally right outcomes; actions can only be considered morally right or wrong by virtue of the morality of the outcome.
morally wrong actions are sometimes necessary