William Lane Craig said this quote
“ By setting such strong, harsh dichotomies God taught Israel that any assimilation to pagan idolatry is intolerable. It was His way of preserving Israel’s spiritual health and posterity. God knew that if these Canaanite children were allowed to live, they would spell the undoing of Israel. The killing of the Canaanite children not only served to prevent assimilation to Canaanite identity but also served as a shattering, tangible illustration of Israel’s being set exclusively apart for God. ”