Destroyed, Lot's daughters, thinking that the entire world had been destroyed, had an incestuous union with their father to perpetuate mankind, for the same reason Kain and Hevel were allowed to marry their sisters. Lot, though, had been told by the visiting angels that only that region would be destroyed, and he knew good and well that there was no such permissibility. The Gemara (Horayos 10b) remarks about this act of incest that it was considered virtuous for Lot's daughters and at the same time shamefully sinful for Lot. Amon and Moav emerged from those unions. Since only the male participant in those unions sinned, the male descendants would emerge blemished and forbidden from entry into the Jewish people, while the female descendants would emerge pure (Rabbeinu Avigdor HaTzarfati to Horayos ibid.). Indeed, the entire Davidic dynasty, including the Mashiach, emerged from Rus, a Moavite woman.
The above-stated law, that the ban against marrying Moavites is limited to male Moavites, is an oral tradition, which was a matter of dispute when Rus converted and Boaz sought to marry her. Boaz eventually did so, with the consent of the Beis Din of Beis Lechem. Rav Shlomo Alkabetz wrote a commentary to Megillas Rus called Shoresh Yishai. In his introduction, he suggests that this Megillah was written in order to publicize the authenticity of this oral tradition, which was necessary to legitimize the Davidic dynasty. Based on what we have written above, we may add that Megillas Rus substantiates the ruling of the Beis Din of Beis Lechem by describing the kindness and compassion of Rus in detail, thus demonstrating that the cruelty that characterizes Moav is clearly not shared by its female members.
It emerges that the moral sensitivities are largely dependent on the pureness of the soul and on spiritual genes that pass on from generation to generation. That is why it is strictly forbidden to mix the pure seed of Avraham, in whose spiritual genes are embedded kindness, compassion, and bashfulness (Yalkut Shimoni §82), with the impure seed of Lot's male descendants.
In closing, it is fascinating to note that Avraham himself eventually decided to separate himself from Lot upon observing his twisted values (see Panim Yafos to Bereishis 13:9). The impure roots of Amon and Moav had sprouted forth even before they were born.