It has to do with the nature of time.
Time is something we experience linearly, as a succession of single moments. We can only act in the present moment; the past is only a memory, and the future only a guess.
An eternal (= outside of time) God is not limited to dealing with reality only a single moment at a time. Instead of "losing" each of his moments to the past or having them doled out in portions, for God, every moment is equally the present.
Thus, it is only from our temporally limited perspective that we can say, "God knew beforehand" - for God, there is no knowing beforehand and no knowing afterward, but only the manifold perception of our present actions. He is omniscient because omnipresent in each moment, equally. I submit that having an audience in this sense does not make our choices any less free. God knows what we will do next Tuesday simply because he is already there watching us do it.