From the perspective of the Israelites, they were purging the Promised Land of people who had committed a variety of sins. The Old Covenant emphasized the “separation” of the Chosen People, distinctive by the mark of circumcision, the restricted diet, the Sabbath observance, etc - all designed to remind them of their exclusive relationship with the One God. They were NOT supposed to “keep” the women (or even the cattle) because they were supposed to remain unmixed with those who were unclean. Other parts of the OT describe the kinds of misfortune that befall them when they give in to the temptation to keep the women and livestock . . .
Against this background the radical nature of the “mystery” that Paul wrote had been revealed in Jesus, that the Gentiles were to be co-heirs with the Jews in the Messianic Covenant, was extreme and shocking.
I think it is impossible for us to accurately tease out from the OT what is the dictated will of God and what is the interpretation of His will by the Israelites of the time and what is the redaction by those in the Exile who wrote down the accounts that had been passed down for centuries, especially as we are reading through the filter of our own time, which has been molded by 2000 years of the revelation of God in Jesus; the God who is both just and merciful, the God who has extended the opportunity for reconciliation to all. The Israelites who wrote the OT did not have this part of revelation. It would not have occurred to them or been credible to them that God their Father was also the Father of their enemies, or that He would have cared about all those Ishmaelite, Edomite, Amelekite babies . . . That is what GRACE is about.
Sally