The problem of evil and the problem of reconciling God’s foreknowledge with free will are usually treated as if they were entirely separate issues. But treating them that way hides the fact that the most popular theist views on them are in conflict with one another.
The existence of evil is most commonly explained as a consequence of free will. This is consistent with the biblical idea of the Fall of humanity. God gave humans the ability to make their own choices, and that means that he cannot prevent us from acting badly. However, most theists also want to say that God knew ahead of time what his free creatures were going to do — and thus knew we would be sinful.