2 Kings 14:27 (ESV)

27 But the LORD had not said that he would blot out the name of Israel from under heaven, so he saved them by the hand of Jeroboam the son of Joash.

The Lord gave Israel a saviour in the person of their own king, Jeroboam II. The Lord was gracious for his people, that is the reason for this prosperity. As expressed, it was not because of their spiritual behaviour or the pious heart of Jeroboam. In fact, Jeroboam stands in line with the heathen kings that were at times used by the Lord to end the misery of his people, like with Cyrus (2 Chronicles 36:22) and Ahasuerus in the Bible book of Esther. Add to this that the Lord had not spoken his final verdict over Israel yet; prophets had indeed spoken warnings but had not yet said that Israel would go into exile. That happened not long after (see Amos 4:2; Amos 6:14; 2 Kings 17:22–23).