First, we do not need to justify anything that God does, as God is just (Romans 3:26). Justice and judgment are the foundation of His throne (Psalm 89:14). He cannot deny Himself (2 Timothy 2:13), so therefore we know everything He does is righteous.
Perhaps this question means, “How do we understand God's decisions to command the use of violence and killing in the Old Testament?”
God did tell the Israelites to kill everyone in the land they were conquering (Deuteronomy 7:1-6). He also gave the reason for this in verses 4-6. The people of that land were idol worshippers engaging in horrible child sacrifice. God knew this sin could tempt the Jews, and history shows Israel did tragically turn to idolatry with infant sacrifice (Jeremiah 32:35).
God’s commands may still seem brutal and unfair to the people living in the land, but there are three things we need to keep in mind:
1. The people who were in the land were idol worshippers, child sacrificers and practicers of immorality. These were abominations to God.
2. God created Adam and gave him life. This gift had one condition: complete obedience. Adam and Eve forfeited life with their disobedience. In mercy, however, God allowed the couple to continue to live for a time. Because they had already received the death sentence, their eventual death was certain and they were considered as dead by God. All of Adam’s children are born in this same dead condition. That is why it was not unjust for God to command the Jews to carry out the inherited death punishment. The life that the people of those nations had already lived was more than they had a right to.
3. God had planned to redeem these people with the death of His own son. He will give them a blessing far above what they were experiencing in the Land before they were killed.
So, why did God allow mankind to live in this dead condition for so long? It was so they would learn why God's ways are so much better than their own. Mankind has attempted to fix conditions brought on by selfishness and greed for thousands of years. However, during the 1,000 year reign of Christ (Revelation 20:4) when man is ruled by a “rod of iron” (Revelation 2:27), no one shall do “evil or harm in all [God’s] holy mountain.” Mankind will see what God had planned from the start: life on a perfect earth, with perfect bodies and minds (Isaiah 35), and love ruling their hearts. Then they will want to do God’s will, and be grateful their sinful life was cut short before they became more degraded, and would have had a harder time learning righteousness in their resurrection (Matthew 11:23,24).