There is a great book called
The NAZI Doctors that gives a lot of insight into how doctors could justify participating in the holocaust. The experiments they performed on the prisoners were important to their mental state, because they had to find some way they could justify that something good would come out of what they were doing.