Even taking out instruction by Jesus, which would be controversial, the story would not have played out correctly without the betrayal of Judas. He had a pivotal role.
A more friendly interpretation would be that Jesus knew Judas would betray him from the beginning and allowed it to happen, because it was God’s Will.