I have encountered this same question online myself. I’ve always found it difficult to answer, but particularly so with anyone not believing in Jesus Christ.
We have always understood God as being loving & merciful as well as Holy & just. People are usually all about the love part, but in our current culture, people think of love as purely emotional or sexual - not sacrificial. Love is seen as the component of mercy which gives sinners (if they even accept that sin exists) a get-out-of-jail-free card from any consequences. They are angry or repulsed to learn that God’s justice allows no such liberties. His ways are higher than ours, & when they see exactly how high, they cry: “No fair! I can’t believe in that!” But yet they want to seat themselves as god - & tell God what to do. His morals don’t align with theirs - or their lack of them.
There is the element of God’s love despite arguments to the contrary. His sovereignty & omniscience, so He knows what will happen.
It is important to note that the Israelites were in a Covenant with God. A Covenant was a bond made through the swearing of an oath. Covenants were a serious undertaking long ago. God’s word & your words were completely binding. The Covenant entered into gave a family status to the parties involved. Failure to keep the Covenant resulted in death.
There is the element of the Israelites entering into the Covenant & accepting the blessings and the curses of said Covenant. This can be found here:
Deuteronomy 28 (BibleHub):
http://biblehub.com/niv/deuteronomy/28.htm
A Covenant is sealed with the shedding of blood. The Covenant between Israel & God was sealed with the shedding of blood.
There is the element of God having the power & the right to pronounce judgment & take life as well as the power & Mercy to restore that life.
A murderer is one who unlawfully takes life. God is not a murderer by that definition. He is God, & therefore all life exists because of Him. He does not want anyone to die:
2 Peter 3 (BibleHub)
8But do not forget this one thing, dear friends: With the Lord a day is like a thousand years, and a thousand years are like a day. 9The Lord is not slow in keeping his promise, as some understand slowness. Instead he is patient with you, not wanting anyone to perish, but everyone to come to repentance.
I don’t think it complete answers the question - and honestly, I think that people who raise such a question are not always necessarily wanting an answer, but more of a reason to distance themselves from God further without attempting to really understand Him - but it helps to form the basis of understanding events after the Covenant.
Also there is the knowledge on man’s part deep within of right & wrong so that none of us is excused. Of the time before the covenant, Saint Paul has this to say:
Romans 5 (BibleHub):
http://biblehub.com/niv/romans/5.htm
I think God’s justice demands that at times some lives will be taken. I think with Him knowing all, He foresees what some people’s rebellion will lead to. In the end, He rules. He alone knows what will be, & out of love for us, our free will can be for life or death.
Just some thoughts…