To understand this passage, we have to distinguish between two uses of the term "world," particularly in John's Gospel. In some cases, it refers simply to the cosmos - all creation - and human beings in general. For example, "God so loved the world that he gave his only Son." (John 3:16)
In other cases, it refers to those who have consciously rejected Jesus and who work against him - and today's passage is an example of that meaning.
On the one hand, we are called to be involved in the world as salt, light, leaven. On the other hands, we can't be naively optimistic about the world, accepting its values indiscriminately.
There's no getting around it. Our faith opens us up to a perspective that goes far beyond what eyes have seen and ears have heard. The reign of God has not yet fully come. In this time between the first coming of Jesus and his coming at the end of history, we will sometimes be at odds with "the world."
These words of Jesus at the supper table are not meant to frighten us, or even make us hostile to the world. Jesus is consoling us. If "the world" sometimes ridicules us for our faith, Jesus says, "Remember that it hated me first."
- Little White Book, Diocese of Saginaw