ANSWER: First, let us take a look at the scriptures concerning your question about Cain.
" . . . Now Abel was a keeper of sheep, but Cain was a tiller of the ground. And in the process of time it came to pass that Cain brought an offering of the fruit of the ground to the Lord. Abel also brought of the firstborn of his flock and of their fat.
"And the Lord respected Abel and his offering, BUT HE DID NOT RESPECT CAIN AND HIS OFFERING . . ." (Genesis 4:2 - 5)
Many have speculated as to why his offerings were not respected. Three factors, however, can be safely assumed as contributing to God's displeasure. The first is the ATTITUDE OF MIND in regard to the offerings. The second is the QUALITY of the offerings. The third is the worship of God was not done in FAITH.
When one considers his jealousy toward his brother that drove him to finally murder him, a poor attitude in giving offerings to God is very plausible. This attitude was likely a factor in offering to God poor quality products rather than the very best.
“You offer defiled food on My altar, but say, 'In what way have we defiled You?' By saying, 'The table of the Lord is contemptible.'
"'And when you offer the blind as a sacrifice, is it not evil? And when you offer the lame and sick, is it not evil? Offer it then to your governor! WOULD HE BE PLEASED WITH YOU? Would he accept you favorably?' says the Lord of hosts." (Malachi 1:7 - 8)
Cain's mental attitude was a key factor in displeasing God. God knows man's inner thoughts. The Apostle Paul's writings attest to the fact that while God may like a person who is generous, he loves those who do so out of a heart of cheerfulness and not grudgingly (2Corinthians 9:7).
In the well-known faith chapter of the New Testament, Hebrews 11, the apostle Paul makes it abundantly clear that Abel had faith in God but that, by implication, his brother lacked it (Hebrews 11:1 - 2, 4).
Our human nature not only can think evil and hinder us to do good works, but it can also ill dispose us toward those who reject evil and are doers of good works like Abel. No one less than Jesus himself attested to Abel's righteousness before God.
". . . that on you may come all the righteous blood shed on the earth, from the blood of RIGHTEOUS ABEL . . ." (Matthew 23:35)
We can acquire more of the mind of God, which Abel possessed, by constantly studying His word. If we do not do this our minds can easily be led to the same attitudes that Cain possessed, which God rejected, and be deceived by the devil who is "the GOD OF THIS AGE . . ." (2Corinthians 4:4).