This question is about the events in Genesis 4, especially v3-5:
{3} In the course of time Cain brought to the Lord an offering of the fruit of the ground, {4} and Abel also brought of the firstborn of his flock and of their fat portions. And the Lord had regard for Abel and his offering, {5} but for Cain and his offering he had no regard. So Cain was very angry, and his face fell.
When we compare Cain and Abel’s offerings we can see why God wasn’t please with Cain’s: Abel brought the very best of what he had — the fat portions of the firstborn of this flock — but Cain just brought ‘an offering of the fruit of the ground’. The description of Cain’s offering is deliberately boring in contrast to the description of Abel’s; it shows that Abel appreciated God far more than Cain did — he appreciated God enough to bring the best he could, but Cain didn’t want to waste his best produce on God.
The Letter to the Hebrews also tells us this; Heb. 11:4&6 says:
By faith Abel offered to God a more acceptable sacrifice than Cain, through which he was commended as righteous, God commending him by accepting his gifts. […] without faith it is impossible to please him, for whoever would draw near to God must believe that he exists and that he rewards those who seek him.
Abel was a man of faith — i.e. he trusted God and had a relationship with him — so his offering was accepted, but Cain did not have faith in God, he did not have a relationship with God, which explains his poor attitude towards him and why he brought an offering he didn’t care about.
Could it not be also a shadow of the new testament, allowing us to see that we cannot get to heaven by the works of our own hands, but by the shed blood of Jesus Christ?