How to Read Difficult Passages in the Bible
There's plenty of things in the Bible that are hard to understand (especially in the Old Testament).
The best way to understand them is by knowing that God is Love.
Read the passage again, and then ask yourself "God is Love. Why is God doing this?".
Remember that God can look thousands of years in the future. He normally won't interfere (respecting free will), but when it comes to things like child sacrifices (again) He will certainly interfere.
God hates sin (but loves the sinner). His judgments are fair.
God is Love.