I am no expert at interpreting Scripture. I have consulted some commentaries on this and have not found anything that I felt worthy of posting. So here is my 2 cents.
God’s foreknowledge of how people use their free-will is something that none of us will fully grasp. But He does know all of those who will not repent. And He does know of those who will harm His people in the future. Since God knew the ones who would cause harm to His chosen people, harm such as physical, and spiritual such as leading Israel into sin, God has called for wiping out all those who will do such a thing in order to prevent it from happening. There are other places in the Bible where God has called for that.
God does allow bad things to happen when good ultimately occurs from it, such as when bad people will repent or His people will grow stronger, but if God knows that nothing good will occur from it but only physical and more importantly spiritual harm, then God will call for such measures. Since He knew that those men and women would not repent and would also lead His people into sin later on, then He called for their destruction.
I hope that helps.