The Doctor's morality was already tainted back in The Silurians (1970). The Silurians had awakened from their slumber and were in some disagreement as to how to integrate with humans. The Doctor said there must be peace. The Brigadier instead committed a genocide and blew them all up. The Doctor's response was....to continue to be the scientific advisor of UNIT. If you threaten the Doctor with no hope of ever traveling in his TARDIS ever again, his morality goes straight out the window. He needed UNIT to try to fix the TARDIS. So he accepted the genocide.