Cain and his younger brother Abel both gave offerings to God. This was well before the life of Moses and the laws that God gave to him, therefore, there was no requirement to give an offering. In fact, there was not even a precedent for doing so. Cain and Abel’s offerings were the first ones recorded in the Bible.
For reasons not fully explained, God accepted Abel’s offering, but not Cain’s. One possible hint is that while Abel’s offering was a choice part of the best that he had, Cain’s gift was merely “some” of what he had. Another hint is found in the New Testament letter to the Hebrews, where Abel’s faith in giving a better offering is affirmed. Implicitly, Cain’s faith was lacking.
Regardless, Cain reacted poorly to God’s snub, becoming jealous of Abel and angry, culminating in the premeditated murder of his brother — the world’s first. However, even after this brutal act, God did not turn his back on Cain. Although punishment was meted, God also provided Cain with protection.
Cain did an evil thing; however, he was not an evil man. Despite Cain’s downfall, he was a man who had sought God, giving a gift that was not asked for or required.