Jesus was obviously familiar with the Hebrew Scripture prophecies in Psalms 41:9 and Psalms 109:8 and so he knew that he would be betrayed by a close associate, though the Scriptures did not specifically name anyone. It could have even been any of his other disciples, (remember the 70 that was sent out at Luke 10:1) or even an unbelieving family member.
And when Jesus selected the men to be his Apostles, he didn't choose a "bad" one just to "fulfill" the prophesy. He spent a night in prayer, showing that he relied on his Father's direction. Since James says that God has nothing to do with 'evil', He would have guided his Son to pick faithful men. (James 1:13)
Even though God can use His foreknowledge, it is inconsistent with God’s qualities and past dealings to think that Judas had to fail, as if he were predestined. At the beginning of Judas' apostleship, Judas was faithful to God and to Jesus. So what Jesus may have meant that “from the beginning” of when Judas started to go bad, Jesus recognized it.
Note the Bible also describes the Devil as being sinful “from the beginning.” (1 John 3:8) But this does not mean from his creation as a faithful son of God, but from the start of his course of rebellion against God. Likewise in the case of Judas Iscariot, Jesus knew “from the beginning,” or at the outset of Judas’ wrongful course, that Judas was the one who would betray him.
(Also See: How Did One of God's Spirit Sons Become Satan the Devil, and What Was His Motive?; Search For Bible Truths)
For more, see:
Predestination / Destiny / Fate / Foreordination - Links to Information (Defend Jehovah's Witnesses)