This is one of seven statements Jesus made about himself, all beginning with the phrase 'I am'. The others are: 'I am the Bread of Life,' (6:25). 'I am the Good Shepherd 'and 'I am the Gate' (10:7 & 11). 'I am the Resurrection and the Life' (11.25), 'I am the way the truth and the life' (14:6). 'I am the Vine' 15:1 & 5).
Jesus went early one morning to the temple in Jerusalem to instruct the people, but was interrupted by the teachers of the law and Pharisees when they dragged in that woman who had been caught committing adultery (8:1-11). There are those who argue that the account of this woman (8:1-11) doesn't fit in with the teaching which follows (8:12) about Jesus being the Light of the World, and that the story about that woman shouldn't be there. But there are three links at least.
Having just rescued this woman from moral darkness and hopelessness it was natural for Jesus to speak about himself as the Light of the World.
As he was in the temple courts (8:2) where huge lampstands were illuminated during the Feast of Tabernacles, it was natural to refer to himself as the Light of the World.
As it was dawn (8:2) with the sun rising, it was natural to refer to himself as the light (Malachi 4:2).
A. The world is in great darkness
B. In the midst of this darkness, Jesus says 'I am the light of the world'
C. How can we benefit personally from Christ, the light of the world, here and now?
Jesus gives the answer in verse 12, 'I am the Light of the world. Whoever follows me will never walk in darkness but will have the light of life' if you want to benefit from any light you must come close to it and follow it. If we want to benefit from the light which only Jesus can give then we must come to him in faith, submit ourselves to him and follow him. If we do that, we will never again walk in darkness.
Sadly so many men and women will not come to Christ. In many ways the next few verses (8: 13-20) illustrate that, as they describe how the Pharisees and Jewish law teachers argued with Jesus. They said (verse 13), 'What you are saying about yourself being the Light of the World, is not valid and we won't accept it.' They spoke like that because of their darkness (v 14). They had no idea who Jesus was, where he had come from or where he was going. Many today are like that, but though they spurn Christ, God the Father affirms him (v18) as the one true light.