Ἰωάννην 15·18 Εἰ ὁ κόσμος ὑμᾶς μισεῖ, γινώσκετε ὅτι ἐμὲ πρῶτον ὑμῶν μεμίσηκεν. 19 εἰ ἐκ τοῦ κόσμου ἦτε, ὁ κόσμος ἂν τὸ ἴδιον ἐφίλει· ὅτι δὲ ἐκ τοῦ κόσμου οὐκ ἐστέ, ἀλλ᾿ ἐγὼ ἐξελεξάμην ὑμᾶς ἐκ τοῦ κόσμου, διὰ τοῦτο μισεῖ ὑμᾶς ὁ κόσμος. 20 μνημονεύετε τοῦ λόγου οὗ ἐγὼ εἶπον ὑμῖν· οὐκ ἔστιν δοῦλος μείζων τοῦ κυρίου αὐτοῦ. εἰ ἐμὲ ἐδίωξαν, καὶ ὑμᾶς διώξουσιν· εἰ τὸν λόγον μου ἐτήρησαν, καὶ τὸν ὑμέτερον τηρήσουσιν. 21 ἀλλὰ ταῦτα πάντα ποιήσουσιν εἰς ὑμᾶς διὰ τὸ ὄνομά μου, ὅτι οὐκ οἴδασιν τὸν πέμψαντά με. 22 εἰ μὴ ἦλθον καὶ ἐλάλησα αὐτοῖς, ἁμαρτίαν οὐκ εἴχοσαν· νῦν δὲ πρόφασιν οὐκ ἔχουσιν περὶ τῆς ἁμαρτίας αὐτῶν. 23 ὁ ἐμὲ μισῶν καὶ τὸν πατέρα μου μισεῖ. 24 εἰ τὰ ἔργα μὴ ἐποίησα ἐν αὐτοῖς ἃ οὐδεὶς ἄλλος ἐποίησεν, ἁμαρτίαν οὐκ εἴχοσαν· νῦν δὲ καὶ ἑωράκασιν καὶ μεμισήκασιν καὶ ἐμὲ καὶ τὸν πατέρα μου. 25 ἀλλ᾿ ἵνα πληρωθῇ ὁ λόγος ὁ ἐν τῷ νόμῳ αὐτῶν γεγραμμένος ὅτι ἐμίσησάν με δωρεάν.
If the world hates you, you know that it has hated me before you were hated. If you were from the world, the world loved its own kind, but because you are not (presently) from the world, I chose you out of the world. For this reason, the world hates you. Remember the word that I spoke to you, ‘The slave is not greater than his master’. If they persecuted me, they will also persecute you. If they kept my word, they will also keep yours. But they will do all these things to you because of my name because they don’t know the one who sent me. If I had not come and spoken to them, they would not have sin. But now, they don’t have a valid excuse concerning their sin. The one hating me, also hates my father. If I did not do the works among them that no one else did, they would not have sin. But now, they have both seen and hated both me and my father. This was done so that the word may be fulfilled which was written in their law, “They hated me for no reason.”
ὅτι δὲ ἐκ τοῦ κόσμου οὐκ ἐστέ (but because you are not (presently) from the world) or (not presently a part of the things that the world does). They are not presently from the world because God has pruned them and Jesus has placed them in the perfect spot to produce fruit. Others may have other takes on this passage, but this makes the most sense. We know that the disciples were "from this world." So, it would make sense for the world to hate one of its own who was not being seen or acting as one of its own.
ἁμαρτίαν οὐκ εἴχοσαν (they would not have sin)
This is an idiom (figure of speech). It means that “they would not have known that they were sinning.” Idioms are very common in both the Old Testament and the New Testament. That's why it's very important to understand how they were used in the ancient world.