What we would all do in certain circumstances doesn’t really bear thinking about too much.
simplypsychology.org/milgram.html
Nobody in the experiment in that link gave the ‘learner’ less than 300 Volts. And there was zero reason to do so other than someone telling them to do it.
Put yourself in that position and ask yourself what you would do if the shock treatment would give information that would save your family.
Yes, it’s immoral. But being immoral doesn’t stop it being, in certain circumstances, the right thing to do.