Military officers (and enlisted, for that matter) don't get to decide or debate the morality of a given order -- only the legality. Officers are only free to disobey illegal orders, not orders they consider immoral.
There's good reason for this. What happens if my superior officer believes that various sexual acts within a marriage are immoral and orders me not to perform them with my own wife? Or if my superior officer believes that marriage itself is immoral and that all soldiers should be single ascetics? It's a way to prevent officers from injecting their personal beliefs and opinions into their commands.
Gotcha. So you would obey an immoral order.
Guess what? There is an ultimate Superior Officer whom you will give an answer to some day.
I would not really wanna try and explain this line of reasoning to Him on that day.
But... that’s just me.