Would you obey an immoral order?
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.