John here mentions a further activity in which Jesus was engaged before he came into the world as a man, and this activity was against an enemy, here called the darkness. I suspect by darkness John means everything that has been affected by sin, which is virtually everything. John’s words indicate that the darkness was trying to obliterate the light that Jesus kept shining.
We can think of the world before the flood. How strong the darkness seemed! Yet the light shone in the hearts of the descendants of Seth because Jesus arranged for it. Although things seemed so weak when the number following the light had been reduced to the family of Noah, we must remember that it was Jesus who was keeping the light shining.
We can move on to the period between the flood and the formation of the people of Israel. How dark those long centuries were and the darkness seemed to be triumphing. Here and there, the light was shining. We can think of Melchisedek and Job, and of Abraham, Isaac and Jacob. Jethro, as well. How did they know the true God? Jesus enlightened them and delivered them from the darkness.
Then there was the period between the formation of Israel and the coming of Jesus. One small nation out of all the nations had the light and the rest were overcome by the darkness. And even in that little nation, there were numerous times when the number who had the light was very small. How many had the light when Jesus himself was born? Yet at whatever period we see the light shining we see the activity of Jesus preventing the darkness from overcoming.