Laws (like morals) are defined by a given society. Different societies, at different times in history, have had different laws and codes of ethics. Over time, those laws and ethical codes have been modified to include new rules and remove old ones, as needed. For example, the idea that murder is both unethical and unlawful was determined (a very long time ago) to be detrimental to society, so it was declared to be unethical and unlawful, except in times of war.
With any luck, war will be ruled illegal and unethical and the human race can focus on more important things, like caring for one another and helping one another and not destroying ourselves.