Chazal say about the Halacha of Y’fas To’ar: this leniency was given only to address the needs of the Yetzer Hara. The Torah understands the plight of the soldier, and allows him to get involved (in the proper way) with a gentile Y’fas To’ar, although normally this is a sin. The Rambam says that if he cannot find kosher food, he is allowed to eat non-kosher meat, pork, and drink non-kosher wine, etc. The Torah understands each individual and his special needs.
The Rambam says that the purpose of a Melech is to go to war, and thereby promote the true religion, fill the world with justice, destroy the forces of evil, and wage the wars of Hashem. All his wars have a religious connotation; to battle the falsehood of Avoda Zara. And if they agree to keep the 7 Mitzvos and throw away their Avoda Zara, they cannot be killed.
