This sounds like a complex question but it’s really quite simple. As Isaiah 40:28 (KJV) says, “Hast thou not known? hast thou not heard, that the everlasting God, the LORD, the Creator of the ends of the earth, fainteth not, neither is weary? there is no searching of his understanding.”
Prophesies fulfilled also prove that the Lord has planned everything out from the beginning. Revelation 1:8 KJV) tells us, “I am Alpha and Omega, the beginning and the ending, saith the Lord, which is, and which was, and which is to come, the Almighty.”
Proverbs 22:2 (KJV) also explains, “The rich and poor meet together: the LORD is the maker of them all.” He knows us thoroughly so he also knows what he has planned for us to do.
The Apostle Paul also wrote of God’s omniscience in 1 Corinthians 2:7 (KJV). “But we speak the wisdom of God in a mystery, even the hidden wisdom, which God ordained before the world unto our glory:”
Paul likewise wrote about God in 2 Timothy 1:9 (KJV). “Who hath saved us, and called us with an holy calling, not according to our works, but according to his own purpose and grace, which was given us in Christ Jesus before the world began,”
God knows even what we think and what future generations will believe. Isaiah 66:18 (KJV) prophesies, “For I know their works and their thoughts: it shall come, that I will gather all nations and tongues; and they shall come, and see my glory.”
I’ll write more about how God is omniscient in my next book called You Think You’re Going to Heaven? Because we can’t explain everything about God doesn’t mean those things aren’t true. His ways are far above ours.