“When you draw near to a city to fight against it and you shall call to it to peace!” (Devarim 20:10)
It is a positive commandment that when fighting a city who we wish to conquer, which is called a voluntary war, that we should promise them that we will not kill them if they will make peace with us and become subservient to us. This means that they must pay taxes to our king and be under our control. If they refuse to make peace with us we are commanded to kill all of the adult males in the city, and to take captive all of the women and children and all the spoils.
Amongst the roots of this commandment are that since the trait of mercy is a good trait, we, as holy people, should conduct ourselves with this trait in all of its aspects whenever we can, even with idol-worshipping enemies. There is also a purpose in this so that our king should have people who are subservient to him and pay him taxes and when necessary can perform his service when necessary without having to spend any money. Killing enemies, on the other hand, has no point, since they want to be subservient to us. Instead, we are showing ourselves to be sadistic and wasteful.
Amongst the laws of this commandment are that one should offer peace in all battles, be they obligatory or voluntary. An obligatory war includes those against Amalek and the seven nations. About all of these it says that if they make peace with us, (by accepting taxes and subservience) and they undertake to keep the seven Noachide commandments, that we may not kill any of them and they will be subservient to us and pay us tax. If, on the other hand, they do not make peace, there is a distinction between obligatory and voluntary wars, in that in an obligatory war we must kill all of them, whereas in a voluntary war we kill only the males. Another distinction is that in a voluntary war when besieging a city one leaves one side open so that they can escape from there, whereas in a war against the seven nations we surround them on all sides. Nevertheless, we inform them first that if they would like to leave the city and go away, they have the right to do so. This commandment applies when Klal Yisrael are in their land, to men who are able to fight, and it is one of those commandments incumbent on the general public and especially on the king and leaders.