John 12:46-47 explains John 3:16-17 and is good to read these parallely.
John 12:46-47
”I have come into the world as light, so that whoever believes in me may not remain in darkness. If anyone hears my words and does not keep them, I do not judge him; for I did not come to judge the world but to save the world.”
Who is Jesus refering to when he says that hasn't come to judge the world? Well, it says who in the sentence before, those who don't keep his words, the goats. So the world means both goats and sheep in John 3:16. So now we we can read John 3:16-17
"For God so loved the world (the whole world, goats and sheep), that he gave his only Son, that whoever (both goats and sheep) believes in him should not perish but have eternal life. For God did not send his Son into the world to condemn the world (goats, all those that choose to not keep his words), but in order that the world (sheep, all those that choose to keep them) might be saved through him."