In his Apostolic Exhortation Verbum Domini n.42 Benedict XVI addressed the dark passages of scripture, where God seems to command, or at any rate approve of, acts of rape, murder, slaughter of non-combatants and so on.
The American apologist Jimmy Akin discusses this passage from Benedict XVI citing a few examples. That post is the first in an ongoing series on The Dark Passages of Scripture.