necessary evil
Short definition from Wiktionary
Noun
- An unfavorable thing that must be done or accepted, especially because the available alternative courses of action or inaction would be worse.
We haven’t written up necessary evil yet: Simple and Standard meanings, examples and a quiz.