There’s an apparent paradoxical relationship between God’s foreknowledge and our free will, as we’ll soon see. A number of explanations have been offered about it by the Medieval thinkers, the Kabbalists, Chassidim, and others, but nearly all of them hearken back to Rambam’s (either explaining it or arguing for or against it), so we’ll present Rambam’s own comments and explain it. He says in Hilchot Teshuvah 5:5:
“Perhaps you’ll then say, ‘Isn’t it true that God knows everything beforehand? [It follows then that] He’d either know if someone will be righteous or wrongful or He wouldn’t. [Accordingly,] if He knows that someone will be righteous, then that person can’t not be righteous, whereas if you claim that even if He knows a person will be righteous that person could be wrongful [anyway], then [you’re saying that] God wouldn’t have known something fully [from the first, which is absurd]’.
“Understand that the response to that is as boundless as the earth and as wide as the sea and that many fundamental principles and lofty mountains are suspended upon it. But just know and understand what I’m about to tell you.
“As we explained in the second chapter of Hilchot Yesodei HaTorah, God doesn’t know with a knowledge that’s external to Him as does man, whose knowledge is separate from his being. God and His knowledge are one [and the same], which is something humankind can never fully understand.
“For just as we can never hope to fully understand God’s Essence, as it’s written: ‘No man can see [or grasp] Me and yet live’ (Exodus 33:20), so too can we never hope to fully understand or grasp God’s knowledge. The prophet referred to this when he said: ‘For My thoughts are not your thoughts, and your ways are not My ways, says God’ (Isaiah 55:8). Since this is so, we consequently don’t have the power to understand how God can know all created beings and their actions.
“But know without a doubt that man’s actions are in his own hands, and that God neither impels nor decrees what he’s to do or not do… “ .
In short, God does indeed know what you’re going to do before you do, yet you’re free to do as you will at that moment. Don’t be confused by the seeming contradiction inherent to that, as in fact God’s knowledge isn’t what you think it is. Thinking you understand God’s knowledge would have you infer that you’re impelled to follow what He knows you will do, but disregard that logical leap: you simply have no point of reference when it comes to God Himself of His knowledge. Simply accept the tradition that you’re free to act as you will, which is a reference you can accept as air-tight.
 Also see Moreh Nevuchim 3:20 and Sh’mone P’rakim Ch. 8.
(c) 2014 Rabbi Yaakov Feldman
Feel free to contact me at email@example.com
AT LONG LAST! Rabbi Feldman’s translation of Maimonides’ “Eight Chapters” is available here at a discount.
You can still purchase a copy of Rabbi Feldman’s translation of “The Gates of Repentance” here at a discount as well.
Rabbi Yaakov Feldman has also translated and commented upon “The Path of the Just” and “The Duties of the Heart” (Jason Aronson Publishers).
Rabbi Feldman also offers two free e-mail classes on http://www.torah.org entitled “Spiritual Excellence” and “Ramchal”.