2 Chronicles 21:7

Howbeit the LORD would not destroy the house of David, because of the covenant that he had made with David, and as he promised to give a light to him and to his sons for ever.

The Lord refused to wipe out the house of David because of the covenant made with David and the promise to give a light to him and to his sons forever, even when Jehoram of Judah had become joined by marriage to the house of Ahab and was following Baal after the pattern of the house of Ahab. In that apostasy he departed from the ways of Jehoshaphat and Asa and walked in the way of the kings of Israel. He made high places in the mountains of Judah and caused the inhabitants of Jerusalem to commit fornication and compelled Judah to do the same, making Judah to go a whoring like the house of Ahab. To secure himself he also slew his own brethren, who were better than himself.

For these evils he was reproved by a written message from Elijah, charging him with forsaking the ways of Jehoshaphat and Asa, walking in the way of the kings of Israel, leading Judah into whoredom like the house of Ahab, and killing his better brethren. The message announced that the Lord would strike his people, his children, his wives, and his goods with a great plague, and would strike him personally with great sickness.

That word was fulfilled when the Philistines and the Arabians came into Judah and carried away all the substance found in the king's house, together with his sons and his wives. No son was left to him except the youngest, Jehoahaz, also called Ahaziah and Azariah. Then the Lord smote Jehoram himself with an incurable disease in his bowels, from which he died after two years, and his son reigned in his stead, so that the house continued and was not destroyed.