For those whom he foreknew he also predestined to be conformed to the image of his Son, in order that he might be the firstborn among many brothers.
Romans 8:29 ESV

Foreknew doesn’t mean that God knew what was going to happen or who was going to do what or even the character of each person who didn’t exist yet. It’s talking about God’s established relationship with those whom he has determined to conform into the image of his Son. "Whom he foreknew" should be translated as "with whom he has established a relationship".