Interesting little note. Within the Tanakh, or the Jewish Old Testament, this verse is Hosea 14:1 instead.
Anyway, God isn’t the speaker here, it is Hosea. And yes, it’s barbaric. It’s a sad historical fact, and this sort of act pops up in a number of places within the Old Testament.
It really only becomes a problem though if you take the Bible as one hundred percent the literal word of God. That everything in it is the word of God. If we step away from that, as most Christians do, then we can reflect on the passage as something that was part of the historical record of the Hebrews. It’s a sad part of their history, as it is a sad part of the history of many ancient peoples.