I liked angellights story very much
I too believe that the most evil thing is the enjoyment of another's suffering. From there there is a gray scale where someone's free will is sacrificed for 'the greater good'/'greater evil'. And yes, this happens when someone's ego/defense mechanisms take over and overrule other living beings rights to their own free will.
How to prevent it? I'd say education and a continuous effort to promote a healthy psyche from childhood is probably your best bet. Considering the variables that go into that, it is always going to be a tough act to balance. But it is known that the 'evilest' of minds usually are more likely to tap into their evil potential when they are raised in precarious circumstances i.e an abusive, oppressive, traumatic and stressful childhood.
Granted, eliminating all stress points in life would not challenge the psyche to grow, but their breaking point is going to be earlier than that of most people - and those people too are far more likely to commit 'evil' acts when preoccupied with survival, and dealing with chronic stress and traumatic events. Perhaps it is not so much the fact that we go through those events, but more that we are not always given the tools to deal with and heal from those events that allows evil to enter into the world.
For all our focus on physical health, emotional healing is often shunned, not recognised as necessary, ridiculed and well, let's face it - we aint as knowledgeable as a species about it just yet. At the same time, it seems to me that there is nothing more important than offering our children (and adults for that matter!) the immediate access to resources to deal with trauma - big and small, in their lives instead of shielding them from it which inevitably fails, or letting them fend for themselves - we wouldn't leave them lying on the floor with a broken leg either. And yet, in many cases, the emotional damage is way more extensive and way more damning than a broken leg would be.
The solution stands upon the edge of a knife - and always will. Achieving balance has never been more important.