I often read jibes at God for being "mean," "spiteful," "angry," and vengeful in the Old Testament and the Qur'an. Let me explain something in really simple terms.
The Bible is not a history book, so it does not record the day to day cultural and societal events and mores at the time. The writers of the books of the Old Testament, and the Prophet (PBUH) were writing scriptural and legal works at the direction of God.
Here is an example. When you read a state penal code that declares murder to be a crime, do you read several pages of discussion about the rate of murder alongside the law? Do you read a historical description of types of murder and crime rates on the same page as the state penal code that prohibits murder, classifies it and defines punishment? No, of course not. It is the same with the Bible and the Qur'an. When God is "angry" it is because something very, very, VERY bad is going on, but the recorders of the Bible and the Qur'an are not writing a history book or the newspaper of the day. If God is angry you can be sure it is VERY BAD deeds by humans that God is angry about.
Here is my second example to clarify things. In the United States, how many people feel that not enough has been done by way of acknowledging the evil of slavery that existed in this country until the end of the Civil War? Almost every year someone asks for more acknowledgment and apology about the evils of slavery. Some even have talked about compensation and so forth over a hundred years after the fact. While people may disagree about remembering and financial compensation, everyone agrees that slavery in the United States was wrong, a horror, and one of the worst chapters in our nation's history.
Well, if you understand that, understand this. In the time of the Old Testament, and in the time of the Qur'an, slavery was widespread worldwide throughout civilization and extremely violent and cruel. What was abhorred in the United States most recently was global and ten times worse in the treatment of slaves during Biblical times and to the birth of Islam.
Think about this. Slavery was so bad that God had to codify the decent treatment of slaves in the BIBLE to the VERY Israelites that God had liberated from their own slavery in Egypt! Why in the world did God have to tell the Israelites how to be decent to their own slaves after they had just experienced brutal treatment under the Egyptians?
I have a news flash. Humans do not have a good track record. When God is "angry" it is because it is over behavior as egregious as what I just described, where liberated slaves (the Israelites) turn around and own their own slaves within decades of their own liberation, and have to be repeatedly told by (and hit over the head) by God about how to be decent. This is just one example. I hope you find this useful and enlightening. Maybe you'll even appreciate how unbelievably patient God has been as humans are dirt to each other.