The time for Jesus' crucifixion was rapidly drawing near. He had just celebrated the Passover with His disciples in the upper room (John 13:1). Judas had been identified as the traitor of the Lord and had left the group. After the instructions in chapter 14, Jesus said, "Arise, let us go hence" (vs. 31), indicating that it was time to leave.
The teachings in chapters 13 - 17 are often referred to as the Upper Room Discourse. There is a disagreement among Bible scholars concerning when the Lord Jesus and the disciples actually left the upper room. Some think they left as soon as Jesus said they should go.
If Jesus was going to leave, how could the disciples be certain they would stay true to Him in the future, when He was no longer there to give immediate guidance? The remainder of this discourse seems to address this concern in great detail.