John 13:11 For he (Jesus) knew who should betray him...
Jesus selected disciples to accompany him throughout His earthly ministry. They formed a very close and tightknit group which provided and modeled encouragement, accountability, and support. I still find it extremely ironic that of all the people in the world to betray Jesus, all the times the Sadducees and Pharisees (religious leaders) tried to discredit and abuse Him, the most shady and disloyal act that we see happen to Jesus Christ happened at the hands of someone from His inner circle.
Although Jesus knew that one of His disciples, Judas Iscariot, would eventually behave in such a disloyal manner, Jesus still treated Judas with love and respect until the very end. In fact, the method of revealing Judas as a traitor involved Jesus giving food to Judas.
It is such a hard concept for me to wrap my head around. How did Jesus deal with continuing His mission unhindered, knowing full well He would be backstabbed in a very public and personal way? I find difficulty sometimes just working and interacting with someone whose personality doesn't suit me let alone someone that I know will eventually bring me bodily pain and shame.
I believe what supported Jesus through this time was a few things. First, He wanted to show the ultimate example of how to work with someone that is a "no win". We often like the low hanging "easy wins" - the sure things. It's easy to devote attention and resources to projects, ideas, even people that we have confidence will bring us a successful return. How often are we willing to go the extra mile and help someone that we know will only take from us, or cause us frustration or extra work? Jesus showed us how to do this by modeling this behavior in His relationship with Judas Iscariot.
I also believe that Jesus was thinking of each of us. He ultimately knew His life would be ransomed for ours and He was willing to do so by any means necessary. From the Cross He prayed to God, basically saying that if there was another way to redeem us and provide peace between humankind and God, He would take it. But, because Jesus knew the Cross was the only way, He was willing to go through it. He was willing to everyday extend grace to Judas, because He knew that would lead to the Cross, which would lead to the Resurrection, and result in a personal relationship for you and for me. He knew that there would be a day we would recognize our need for Him and desire the peace with God that passes all understanding.
These things motivated Jesus to maintain His relationship with Judas, even though He knew how it would end. Ultimately, you were worth it. And He would love nothing more than to daily demonstrate to you why and how. Ask Him.