It comes from the Bible which often refers to good as light and bad as dark/darkness.
Again Jesus spoke to them, saying, “I am the light of the world. Whoever follows me will not walk in darkness, but will have the light of life.”"
John 8:12 ESV
But the path of the righteous is like the light of dawn, which shines brighter and brighter until full day."
Proverbs 4:18 ESV
This is the message we have heard from him and proclaim to you, that God is light, and in him is no darkness at all."
1 John 1:5 ESV
There are many more verses but these get the point across.