"Even from every evil action, there may still be found some measure of goodness."
This is a teaching from the Zohar ( Book Of Splendor), expressing the great value of learning from our mistakes.
We are not perfect. That is why our souls have come to this plane of existance. In fact, according to Kabbalistic thought, we reincarnate approximately 6,000 times untill we reach total correction. That's one heck of a learning curve!
We come here to learn, through the experiences-lessons, the things our souls require so we may transcend from the material plane of the ego. When we commit a wrong doing, and come to understand the harm we have caused, why we have acted the way we did, and address the weakness within ourselves, and "make good" to those we have wronged, we can correct ourselves, and evolve further.
So, when an evil action is committed, if we can learn from it, and correct the trangression within ourselves, there is indeed, some measure of goodness that came from it- we have grown a little more.