Foreknowledge is not an issue here. You are looking at it through your tainted Calvinistic lenses. The Bible teaches that God will someday judge people according to their works (good or bad) and reward them accordingly. That is written all over the Bible. God doesn’t judge people according to his foreknowledge of how they will act, but according to the reality of how they have acted:
John 5:
28 Marvel not at this: for the hour is coming, in the which all that are in the graves shall hear his voice,
29 And shall come forth; they that have done good, unto the resurrection of life; and they that have done evil, unto the resurrection of damnation.
It doesn‘t say that he will judge them according to his “foreknowledge,” but what they have actually done. And the temptations of the devil is required for them to be able to make that choice or decision. Job is a good example. God allowed Satan to tempt Job to prove his integrity and righteousness, and he passed the test. Did God know beforehand in his foreknowledge that Job would pass the test? Of course he did! But he still have to put him through the test. That applies to all of us, not just Job.