Summary: Our heart attitude is what God seeks in whatever we offer to Him. When what we do is unacceptable, God will give us a chance to resubmit.
Cain hated his brother as long as he was Abel! Cain’s parents disobeyed God and introduced sin into the world, and Cain became the first murderer. Sin’s beginning in Genesis 3 (quickview)  appeared small; our first parents broke a seemingly insignificant command of God. But in so doing, they rebelled against God’s way and brought corruption to the world. They turned a garden into a grave. Genesis 4 (quickview)  shows how sin spread, how it turned brother against brother. Yet in this dark chapter God shines a ray of hope.
Cain was Adam and Eve’s oldest son, their first-born. Eve mistakenly assumed that he was the fulfillment of the promised seed that would crush the serpent’s head. Instead he dashed all her hopes for the world. Those who study birth order say that nothing is more devastating than for a first-born to be bettered by a younger sibling. First-borns tend to be the most successful. I’ve also heard it said that first-borns will forgive their parents of anything but having a second child!
Cain and Abel each presented offerings to God, but only Abel’s was acceptable. Cain was a farmer and Abel was a shepherd. There’s nothing here to suggest that Abel’s profession was in any way superior to Cain’s. Abel sacrificed an animal from his herd; Cain presented produce from his fields. We’re not told why God rejected Cain’s offering, but one explanation is that God may have wanted a blood sacrifice. Just as animals were slain to cover Adam and Eve’s shame, perhaps animal sacrifice may have been necessary to demonstrate the seriousness of sin.
However, God’s rejection of Cain’s offering and His favoring Abel’s is more likely because God knew the heart attitudes that accompanied the two offerings. Cain may have given begrudgingly. The value of an offering depends on the spirit in which it is given. Cain’s problem was not connected to his livelihood, but with himself. In Hebrews 11:4 (quickview)  we’re told, “By faith Abel offered a more excellent sacrifice than Cain.” Abel submitted to God, while Cain was reluctant to honor God. Maybe he resented how his parents were driven from Eden.
Cain’s rejection must have felt overwhelming. Nonetheless, God pulled Cain aside and encouraged him to try again. God confronted Cain with his unjustified, brooding anger. In verse 7 God tells Cain, “If you do what is right, will you not be accepted? But if you do not do what is right, sin is crouching at your door; it desires to have you, but you must master it.” God graciously gave Cain another opportunity to do right. The choice was his. Cain’s blood was boiling, but if he could just get around his frustration, get over it, rise above it--he could master it. But Cain didn’t handle correction well; he refused to heed God’s counsel, and things quickly got worse. His stubborn silence gave way to slaying. Just like Cain, we also have to confront our urge to choose evil; it lies at our doorstep.
Just like the serpent that tempted his parents, sin sought to influence Cain, and swayed him the wrong way. When temptations come--and they will--like a raging storm, they will always try to gain the upper hand. Are we mastering our temptations, or encouraging them? We either master sin or become enslaved by sin. Cain was consumed by anger at God which he directed toward his younger brother.