Now we have another reason why they need protection, which is because of the hatred of the world. First he mentions the benefit he had given his disciples; secondly, the hatred of the world for them (v 14); and thirdly, he asks the Father's help to protect them (v 15).
He says, I have given them your word, which I have received from you: "I have given them the words which you gave me" (17:7). Or, I have given, that is, I will give them, by the inspiration of the Paraclete, your word, that is, the word about yourself, which is the greatest of gifts and benefits: "I will give you a good gift, d...o not abandon my law" (Prv 4:2).
The result of this is the hatred of the world: because they have received your word, the world has hated them: "Blessed are you when men hate you" (Lk 6:22); "Do not wonder, brethren, that the world hates you" (1 Jn 3:13). The reason for this hatred is that they have left the world. For the word of God causes us to leave the world since it unites us to God, and one cannot be joined to God without leaving the world, for one who loves the world does not have a perfect love for God. Thus he says, because they are not of the world: "I chose you out of the world, therefore the world hates you" (15:19). For it is natural for one to love others who are similar: "Every beast loves its own kind, and hates the others" (Sir 13:19); "The very sight of him is a burden to us," and this is "because his manner of life is unlike that of others" (Wis 2:15).
Then he mentions the model according to which they are not of the world when he says, even as I am not of the world. This should be understood to refer to their affections, for just as Christ was not in the world by his affections, so neither were they. It does not apply to their origin, because at one time they were of the world, while Christ was never of the world because even considering his birth in the flesh he was of the Holy Spirit: "You are of this world, I am not of this world" (8:23).
Source: Commentary on John