The word κόσμος (cosmos) is very common in the NT with a variety of meanings. See appendix below. The clue to the word's meaning in the gospel of John is actually given in John's prologue where it occurs in John 1:9, 10
The true Light who gives light to every man was coming into the world.
He was in the world, and though the world was made through Him, the
world did not recognize Him.
Note that whatever "the world" is here, it has sentience and so cannot be an inanimate planet but must be the humanity because it "did not recognize" Jesus, but should have. Indeed, under meaning #7 (see appendix) sub-meaning 'b', BDAG provides this helpful remark:
the world, and everything that belongs to it, appears as that which is
hostile to God, ie, lost in sin, wholly at odds with everything
divine, ruined and depraved ... John 1:10, ... this world (in contrast
to the heavenly realm), John 8:23, 12:25, 31a, 13:1, 16:11, 18:36,
etc. ... this world who is ruled by ... the prince of this world, the
devil, John 12:31b, 16:11, 14:30, etc. See also John 17:25.
That is, κόσμος (kosmos) in the Gospel of John appears to be the unsaved people of this world who need to be saved and thus, do not recognize Jesus but obey "the prince of this world", the devil.
APPENDIX - Meanings for κόσμος (kosmos) in BDAG
The word κόσμος occurs about 186 times in the NT and has a range of meaning. Here I list only the 8 main meanings from BDAG
- that which serves to beautify through decoration, adornment, adorning
- condition of orderliness, orderly arrangement, order
- the sum total of everything here and now, the world, the (orderly) cosmos
- the sum total of all beings above the level of animals, the world
- planet earth as a place of habitation, the world
- humanity in general, the world
- the system of human existence in its many aspects, the world [mostly unsaved humanity]
- collective aspect of an entity, totality, sum total