The idiom "necessary evil" refers to something that is unpleasant or undesirable, but is required or unavoidable in order to achieve a desired outcome. It suggests that although we may not like or enjoy this particular thing, we recognize its importance or necessity in certain situations. It is often used to describe tasks, actions or decisions that we reluctantly accept because they are necessary for a greater purpose or goal.