For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life.

John 3:16-17 NIV

For God so loved – This does not imply that God approved of men’s behavior, but rather that he had benevolent thoughts for people or was “earnestly desirous” of their pleasure. God despises evil, but he still desires the happiness of people who sin. “He despises sin but adores the sinner.” A father can love his child and care about his well-being while fiercely opposing his child’s behavior. When we approve of another’s behavior, we are loving complacency; when we merely want them to be happy, we are loving kindness.

The world is all of humanity. It does not refer to any particular region of the planet, but to man as a whole – the race that had rebelled and deserved to die. See also John 6:33 and 17:21. Several situations demonstrated his love for the world, or for all humans, in giving his Son:

The entire planet was in ruins, vulnerable to God’s wrath.
Everyone was in a bleak situation.
God sent his Son. Man had no right to him; he was a gift, an undeserved gift.
He subjected him to excruciating pangs, including the agony of death on the cross.
It was for the entire planet. Jesus experienced “death for every man,” according to Hebrews 2:9. Christ “died for all,” according to 2 Corinthians 5:15. 1 John 2:2 says, “Christ is the propitiation for the sins of the whole world.”
That he gave was a gratuitous and undeserved gift. Man had no claim: and since there was neither eye to pity or arm to save, God pleased to place his Son in the hands of men to die in their place, Galatians 1:4; Romans 8:32; Matthew 22:19. It was a simple act of love; a statement of eternal compassion and a desire that sinners not perish forever.

His only-begotten Son – See John 1:14 comments. This is the finest form of love that we can imagine. If a parent could or would give up his only son to die for the sake of others who are guilty, he would demonstrate greater love than could be demonstrated in any other way. Therefore it demonstrates the depth of God’s love that he was ready to deliver his only Son into the hands of sinful men in order for him to be slaughtered and thereby save them from eternal anguish.