Kindness can defer anger
God told Abraham that his descendants would dispossess the inhabitants of Canaan (Gen 13:14-17, Gen 15:7, Gen 17:8). This came to pass in the days of Joshua. The first city the Israelites came upon in their conquest was Jericho (Josh 2-6). The people of Jericho had put their city on lock down for fear of Israel. Their wall was thick enough to have houses on it. A harlot named Rahab lived in one of those houses with her family. Joshua sent two men to spy out the city before they attacked. They ended up in Rahab's house and she protected them. As the men were leaving to return to Joshua she made them promise they would spare her and her family because of the kindness she had shown them, and they did. Although her house was on the wall that fell, she and her family lived. She joined the Israelites and became an ancestor of Jesus Christ (Mt 1:5). She had been set to be destroyed for over 400 years by the word of God, but because she showed kindness, her judgment was deferred. Archeologists state they have discovered the wall of Jericho and that there is a short section which was not toppled. This appears to be the place of Rahab's house.
When Saul went to battle against the Amalekites, he sent a message to the Kenites who lived among them to flee so they would not die in the battle (1Sam 15:6). He did this because their ancestors had shown kindness when Israel was in the wilderness on the way to the promised land about 400 years earlier. The Kenites were one of the nations set to be destroyed by God's promise to Abraham about 1,000 years before Saul (Gen 15:19, Num 24:21-22). Moses' father-in-law was a Kenite (Jud 1:16, Jud 4:11). He came to Moses in the wilderness, brought his wife, gave him counsel, and stayed for a while (Ex 18). Moses' brother-in-law also stayed to assist Moses (Num 10:29-33). All that time later, Saul, who had his own spiritual issues, remembered the kindness of the Kenites and spared them from being destroyed with the Amalekites who were judged by God (Ex 17:14-16, Num 24:20, Deut 25:17-19, 1Sam 15:2-3). Also, it was Jael the wife of a Kenite who killed Sisera the captain of the Canaanite army (Jud 4). Her husband was a descendant of Moses' father-in-law and had separated himself from the other Kenites (Jud 4:11). David also showed kindness to the Kenites and sent them a gift (1Sam 30:25-29).
Although Saul had attempted to kill David at least 20 times (1Sam 18-26), David had a close friend in Saul's son Jonathan (1Sam 18-23). Jonathan knew David was going to replace his father as king and made him promise to be kind to his household (1Sam 20). After Saul and Jonathan died and David became king, he sought to display kindness to the house of Jonathan (2Sam 9). There was a son of Jonathan named Mephibosheth who was lame, and David took him in and fed him at his table. After Saul's death, the men of the city Jabeshgilead recovered his body from the Philistines and buried it (1Sam 31:11-13). When David heard of it, he blessed them for the kindness they had shown Saul (2Sam 2:4-7).
On the other hand, a failure to show kindness can also trigger the judgment of God. After the death of Gideon who had been the instrument of God to deliver Israel from the Midianites (Jud 6-9), the Israelites failed to show kindness to his family (Jud 8:33-35). This began another cycle of backsliding, civil war, and the judgment of God (Jud 9). As mentioned above, the Amalekites failed to show kindness to the Israelites and instead attacked them, thus triggering the judgment of God (Ex 17:14-16, Num 24:20, Deut 25:17-19, 1Sam 15:2-3). Nahash the king of Ammon had been an enemy to Israel in the days of king Saul (1Sam 11), but became a friend of his successor David. After his death, David sent messengers to his son Hanun to comfort him over his father's death (2Sam 10). Instead of receiving them with honor, he shamed them and sent them back. Then Hanun hired the Syrians to help them attack Israel. David's army defeated them both, costing them both dearly and completely unnecessarily.
Joash became the king of Judah at the tender age of 7 (2Chr 24). Clearly, he needed some adult mentorship, especially at the first. The priest Jehoiada provided this. He also was responsible for protecting him from the evil Athaliah who wanted him dead, and for arranging his installment as king (2Chr 22-23). After Jehoiada's death, Joash backslid, and when Jehoiada's son Zechariah called him and the people to repentance, he had him killed. "Thus Joash the king remembered not the kindness which Jehoiada his father had done to him, but slew his son (2Chr 24:22)." As he was dying, Zechariah prayed, "The Lord look on it, and require it". This not only triggered the judgment of God then, but Jesus said that the innocent blood from Abel (Gen 4:10) to Zechariah would be required of the generation of those who were plotting to kill Him (Mt 23:35).
We cannot save ourselves by our own works (Eph 2:8-10). The basis of our salvation is not our righteousness, but Christ's (Rom 5:18). That does not excuse us from repenting and doing the will of God (Titus 2:11-12). However, our attitude goes a long way in determining whether we find grace or judgment. Those that harden themselves against God cannot have faith in His mercy, and those whose hearts are tender toward God and respond to Him correctly can hope in His mercy (2Ki 22:19, Prov 28:13, Eze 11:19, Eze 36:26, Heb 3, Heb 11). Even Ahab forestalled the judgment of God by humbling himself (1Ki 21:22-29).