We know Cain to be a murderer — and we vilify him for it. What we often fail to consider is that Cain had a relationship with God.
Consider that Cain gave an offering to God that wasn’t requested or expected. (Cain lived centuries before God instructed Moses about the need to give him offerings.)
Also, consider that Cain also had a personal relationship with God, that is he talked to God and was able to be in God’s presence.
Given this, one might conclude that aside from one terrible act, Cain was a good guy, a God-loving dude. Perhaps like you and me.
Even so, this one act — his only recorded failure in life — needed to be punished. Justice demanded it. And as a just God, he meted it out.
So God sent Cain away, away from his presence. But not angrily or out of spite. For despite a need to punish Cain for his grave error, God lovingly put a mark on him to protect him from being killed by others.
God justly punished Cain — and then lovingly protected him.