" His counsel or decree was the ground of His foreknowledge. So again in Rom. 8:29. That verse opens with the word “for,” which tells us to look back to what immediately precedes. What, then, does the previous verse say? This: “All things work together for good to them...who are the called according to His purpose.” Thus God’s foreknowledge is based upon His “purpose” or decree (see Psa 2:7). "
― Arthur W. Pink , The Attributes of God