Verses 21-29:
The text is Moses’ prophetic warning of what would later happen to Israel when the nation turned from Jehovah to the gods of their heathen neighbors. The Books of Kings and Chronicles give the history of such kings as Jeroboam I, Ahab, Manasseh, and others who sold out to idols, and led Israel to partake of their worship. The judgments of Assyrian and Babylonian captivity resulted in the devastation of the Land itself, as a dramatic testimony of God’s judgment upon their sins.
The greatest devastation of Israel’s Land came about following the Jews’ rejection of Jesus as Messiah. For centuries the Land was barren and desolate, mute witness of Divine Judgment poured out upon the rebellious nation.
Compare verse 23 with Genesis 19:23-29.
"Secret things" refers to God’s eternal purpose of the ages. This is known only unto Himself. Some of His purpose He has chosen to reveal to man. But that portion of His purpose which He has not revealed belong to Himself, and man is to leave those things with him, cp. Matthew 24:36.
God has chosen to reveal some portions of His eternal purpose, in His written Word. The reason: that men might learn and put into practice His law.