The government was given the exercise and responsibility for capital punishment. The reason given was simple. And all Israel shall hear, and fear, and shall do no more any such wickedness as this is among you. It is a deterrent. It cannot bring back the life of the murdered, but it secures society and brings a sense of justice to the grieving.
War is a horrible thing.
It should be avoided at all costs. William T. Sherman, one of the first practitioner of total war, once said, War is hell. And it is. No amount of romanticism, patriotism, and pride can replace a son or daughter lost to the whim of Ares. Vietnam and the invention of the TV camera that brought the horrors of battle into the living rooms of Mom and Pop back home ended those foolish notions.