"I, at least, am a Good Person(TM), so if I do it, then it'll be a Good Person who gets to benefit from this thing."
Or
"Pulling the lever is something a Bad Person would do. Any Good Person forced to pull the lever would hate it. By pulling the lever, I am not actually a Bad Person (though I might superficially appear that way). I am actually making a noble sacrifice here to save other from moral conflict, which means that despite doing something Bad, I am a Good Person"
They can get very creative with their mental gymnastics