A necessary evil is an unsavoury thing (an evil) that someone believes must be done or accepted because it is necessary to achieve a better outcome—especially because possible alternative courses of action or inaction are expected to be worse. It is the "lesser evil" in the lesser of two evils principle, which provides that when given two bad choices, the one that is not as bad as the other is better than the one that is the greater threat.
The Oxford Dictionary of Word Origins asserts that "[t]he idea of a necessary evil goes back to Greek", describing the first necessary evil as marriage, and further stating that, "The first example in English, from 1547, refers to a woman." Thomas Fuller, in his 1642 work, The Holy State and the Profane State, made another of the earliest recorded uses of the phrase when he described the court jester as something that "...some count a necessary evil in a Court". In Common Sense, Thomas Paine described government as at best a "necessary evil".
Evil as a concept is defined by the fact of acts done, considered to be contrary to morality, in other words, sinful, and the execution of any act by an individual, the defining value of the act, is harm is done (in an archaic sense, this indicates acts causing repulsion or discomfort),  additionally, the act is classified as, profoundly immoral. 
This being true, the use of the term "evil" in the phrase does not necessarily indicate that the thing being characterized as a "necessary evil" is something that is generally considered an "evil" in the sense of being immoral or the enemy of the good. In Fuller's use of the phrase, for example, there is no implication that court jesters are evil people, or having one serves an evil end. The term is most typically used to identify something that is merely an inconvenience or annoyance. Where an author suggests that, "[P]aperwork is a necessary evil, despised but handled with the understanding that a mistake – even a trivial one – could be costly." it is understood that the author is not deeming "paperwork" to be wicked, immoral, or evil in senses comparable to those.Some thinkers specifically reject the idea of anything that is actually "evil" being necessary. This may manifest as an admonition for moral people to avoid participating in the activities that are perceived as evil:
The concept of "necessary evil" is an idea that must be thoroughly rejected. Evil is not necessary, and to accept it as such is to perpetuate it. Evil must be opposed, rejected, and avoided at all costs. It should never be viewed as something that we must unavoidably and inevitably participate in. We trivialize evil when we refer to it as "necessary."
Alternately, this may manifest as a call to eliminate systems that contain aspects perceived as evil, and replace them with systems that avoid these aspects. For example, speaking of political parties in the Parliament of the United Kingdom, one author wrote:
To say of anything that it is a necessary evil (it is often said of examinations, as of parties) is to give away all morality. It is almost a contradiction in terms. That which is necessary can hardly be evil. If that which is bad is unavoidable, then the game of morality is up. We are involved in a vicious circle from which there is no escape except in the denial of one premiss [sic] or of the other. Either the thing is not necessary, or it is not evil. A non-moral system might have no difficulty in admitting the conception of a necessary evil, but unfortunately it would also exclude the conception of evil altogether. Whatever may be argued philosophically on the point, the idea of a necessary evil is a fallacy as urged in excuse of party, for those who urge it are saying what they would deny if expressed in other terms.
They would certainly say that it was wrong to charge a man with evil conduct who had done only what it was impossible for him to avoid doing. In that case they would say it was not evil; it was only unfortunate or sad. For the same reason party, if necessary, is not evil. But they do not want to say that, for they are convinced that party is an evil. Therefore they must take the alternative and admit that it is not necessary; and their excuse for party is gone.
Necessary Evils are those which cannot be avoided without incurring greater; Among the necessary Evils are the Laws themselves; because they prohibit us to do certain things, or oblige us to do certain others; and consequently they deprive us of a Portion of Liberty, which is the greatest Good. But what would be the Consequence if we had no Laws?
- Julia Cresswell, Oxford Dictionary of Word Origins (2010), p. 156.
- Thomas Fuller, The Holy State and the Profane State (1642), p. 182.
- Richard Van Ingram, Philosophy and Other Bad Habits (2011), p. 112.
- dictionary definition Merriam-Webster Accessed February 11, 2018
- dictionary definition Oxford Dictionaries Accessed February 11, 2018
- Sim B. Sitkin, Laura B. Cardinal, Katinka M. Bijlsma-Frankema, Organizational Control (2010), p. 143.
- Gebre Menfes Kidus, Mystery and Meaning: Christian Philosophy and Orthodox Meditations (2011), p. 225.
- Harold Hodge, "Ex Parte" The Nineteenth Century and After (1924), Vol. 95, p. 205.
- Philip Mazzei, reported in Margherita Marchione and Stanley J. Idzerda, eds., Philip Mazzei: Selected Writings and Correspondence (1983), p. 427.
dictionary definition Cambridge Dictionary Accessed February 11, 2018