What to do? Do they allow the torture to continue, possibly for centuries, for the benefit of the people - or do they set the creature free at the cost of the lives of the people.
Spoiler alert! The creature is set free, but everyone lives - and the ship travels even faster than before because the Starwhale's purpose is to help people, and works better when not attacked. (Similar to the tendency for society to inflict pain on the environment rather than co-operate with it for the benefit of all ... but that's another story)
Jesus is recorded as saying:
If you cling to your life, you will lose it; but if you give up your life for me, you will find it.and also
What do you benefit if you gain the whole world but lose your own soul?
This second quote is key to the Doctor's anguish as he was repulsed by the idea of saving one race at the deliberate expense of another.