Cain and Abel
I've heard several sermons (and John MacArthur agrees) that somewhere along the line, God had commanded animal sacrifices. So when Cain brought "fruit of the ground" (we don't even know if it was the best of the crops, or the first harvest, or what), he wouldn't be following a command of animal sacrifice.
It could be that Cain's attitude about the offering wasn't correct.
Either way, Cain's offering wasn't accepted, and he was angry about it. And though Adam and Eve and their sons obviously still spoke with God, Cain took his anger out on his brother, Abel.
And like his parents before him, he didn't want to face his sin.
Cain doesn't repent in these verses, he just complains that God handed him a death sentence.
God's mercy is ever present. Even in Cain's sin, his unrepentant heart, his turning from the presence of the Lord, God protects him from being killed the same way he, Cain, killed Abel.
God gives us every chance we need. His mercy and love never fails.