Without those noble lies, those progressive fictions, we’d be stuck in the state of nature, which would invite a war of all against all, as Thomas Hobbes said.
The law doesn't ban "killing." It bans certain killings. Making war is to murder as driving is to drunk driving. The fact that killing or driving is involved is irrelevant to the status of the act.
The Preamble to the US Constitution deals with the problem. The states created the Constitution to "insure domestic Tranquility" and "provide for the common defence." Domestic tranquility is insured by laws against murder. The common defense is achieved by killing in war. War entails doing to the enemy what must be done to win. If that's killing, then killing is what is done. The "killing" is a morphological coincidence.
It is good for domestic tranquility that humans internalize a taboo on murder, and our internal discriminators (as opposed to our philosophizing brains) can't draw a bright line between murder and war. That's why killing in war is so traumatic. The laws of war, which treat killing to no strategic advantage as murder, enable the soldier to avoid the trauma of killing when the killing isn't militarily necessary. The device does not always work, as Cpl. Upham demonstrates. But outliers gotta outlie, and we can't build a philosophy on them.
Criminalizing some things done by soldiers is not the same thing as "legalizing" war. There is no sovereign with the power to legalize war, only parties with the ability by convention to constrain it. Does it make sense to say we have "legalized" driving just because we have not banned it entirely but have criminalized doing it under the influence?
Pacifism serves the winner of the most recent war. We cannot eliminate natural brutality, because it serves us too well in times of environmental stress. Chimps do make war, as do the big cats protecting their hunting grounds. You say that a "poor nation’s engaging in violence to feed its citizens would likely be regarded as terrorism." By whom, and why do they get to say? For me, whether terror as a tactic is morally wrong depends on whether there are other options. A group should not accept poverty. But if war is politics continued by other means, it's the failure to try politics that generates the righteous condemnation of the tactic.