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. If we say we have fellowship with him while we walk in darkness, we lie and do not practice the truth. But if we walk in the light, as he is in the light, we have fellowship with one another, and the blood of Jesus his Son cleanses us from all sin. (1Jn 1:5-7)
The contrast here couldn't be much starker. God is light. Anything else is darkness. There is a bright, clear dividing line and people are on one side or the other. God is not merely much, much better than us, He is completely light. His perfection is complete. Indeed anything contrary to God is inherently darkness. To accuse God of unrighteousness or cruelty or injustice misses the mark, because it is God Himself who determines what is righteous, merciful and just.
Saying we have fellowship with Him while we are walking in darkness. First, what is this darkness? It certainly seems from John's other writings that the light of which he speaks is always the light of the truth of Christ. Can someone deny Christ and say they are in fellowship with God? Certainly not. There is no fellowship or reconciliation with God outside of the blood of His Son. he cannot have "dialogue" with other faiths that deny Christ to find "common ground" because there is no common ground between those who belong to Christ and those who deny Him.
Darkness is not, it seems, merely sin but a darkened mind that is not set on Christ. Even the most virtuous person, even the wisest scholar, the most pious religious leader who does not know Christ is in darkness and lost. Walking with Christ is not an academic exercise, it is not merely parroting the right theology or memorizing the right confessions or doing good deeds. There are many who claim to follow Christ, but by word and deed and doctrine their profession is shown to be false. That was true in the first century and it is true today.
Certainly there is also the element of darkness as being sinful opposition to God. Look at something else John wrote in the same basic theme as this, in the third chapter of the Gospel according to John:
And this is the judgment: the light has come into the world, and people loved the darkness rather than the light because their works were evil. For everyone who does wicked things hates the light and does not come to the light, lest his works should be exposed. (Joh 3:19-20)
This sets out the reality of man. Men by nature are not seeking God, in fact the exact opposite is true. Man outside of the new birth hates God and loves his own sin. The Gospel of Jesus Christ exposes man's deeds as evil and causes sinners to revile Christ for exposing their sins as being wicked. Even though man hated God, God first loved us and sent His Son to redeem His elect by the blood of His cross. Unless you understand the nature of man, how lost we were and how much we hated God, you can never truly understand how gracious the cross is. You need to understand the darkness to really appreciate the light.