If we carefully read the story of the people of Israel, we will notice that God is incredibly patient and kind. Much more than we think he is. But ultimately, he must judge those who are willfully disobeying and breaking his laws.
Because of his great mercy, God rescued the people of Israel from slavery in Egypt. He parted the waters of the Red Sea for them to pass through and escape Pharaoh’s army who drowned in the sea. Later on, God provided food and water for his people in the desert. Sadly, they continued to not trust God and kept on disobeying him. Therefore, God punished them. For 40 years, they had to wander through the desert until the disobedient generation had died. Only their children, the new generation, were allowed to enter the land that God had promised them.