Yes, God knew it would happen.
You are tapping on the window of “the problem of evil.” There have been countless sermons, Bible studies, and books on the subject.
God can stop evil. Why doesn’t He? God could have prevented the Fall. Why didn’t He?
There is probably not enough bandwidth on FR for me to address the topic, but it is addressed to a large degree in Romans chapter 9.
I will conclude by saying that while God did not prevent all evil, He prevents a whole lot of it. Also, He provided a way out at immeasurable personal price.
I recommend an inexpensive book. “God and Evil, the Problem Solved” by Gordon H. Clark. It is about five bucks and is an in depth, biblical examination of the question.
How is it, that you KNOW these things things about God?
I think the answer is rather simple. Free will and the ability to choose good cannot occur unless the opposite of those things exists and can be understood.
There is no happiness without sadness.
No health without disease.
No compassion without suffering.
Me mercy without justice.
No love without hate.
No life without death.