There are many unrecorded parts of history. One of those parts is the period of time right after the birth of Cain and Abel. During this time, Cain and Abel grew from infancy to maturity— Eve likely gave birth to more children. But the sinfulness of humanity did not disappear during this time. Man still remained cursed and fallen— a fact which is clearly proven in the next verses of Genesis, which describe how the first murderer in history came to execute his crime.
So it came about in the course of time that Cain brought an offering to the LORD of the fruit of the ground. Abel, on his part also brought of the firstlings of his flock and of their fat portions And the LORD had regard for Abel and for his offering; but for Cain and for his offering He had no regard... (Genesis 4:3-5).There is some debate as to why God had regard for Abel's offering and not Cain's. Some suggest that God had revealed to man some sort of animal sacrificial system, similar to what would later be put into place in Israel. Thus the reason God did not regard Cain's offering was because it was not an animal sacrifice.
While such reasoning may seem speculative, the issue comes up once again in the time of Noah. In Genesis 7:2, Noah seems to be aware of a distinction between clean and unclean animals (for more information see How Did Noah Know Which Animals Were Clean?)
Regardless of what Cain and Abel knew about clean and unclean animals, the passage definitely focuses on the quality and heart behind the offering. Abel gave the firstlings of his flock and of their fat portions. It wasn't just any offering— it was the best he had.
Cain, however, simply gave an offering. While he did give an offering, he did not give it in the right manner. He was a hypocrite. He simply gave so that he might appear to be righteous, but God saw through Cain's false motives: for God sees not as man sees, for man looks at the outward appearance, but the LORD looks at the heart (1 Samuel 16:7). And because of the heart behind each offering, the LORD had regard for Abel and for his offering; but for Cain and for his offering He had no regard.
Cain and Abel: Anger - Genesis 4:5-7
Cain and Abel: Two Routes - Genesis 4:1-2
The Fall: No Repentance - The Christian Worldview
The Fall: Humanity Cursed - The Christian Worldview
Why Is Sin Unavoidable? (Part 1) - The Christian Worldview