'The devil tries to soil and defile every good thing a man would do by intermingling with it his own seeds in the form of self-esteem, presumption, complaint, and other things of this kind, so that what we do is not done for God alone, or with a glad heart. Abel offered a sacrifice to God of the fat and firstlings of his flock, while Cain offered gifts of the fruits of the earth, but not of the firstfruits; and that is why God looked with favor on Abel's sacrifices, but paid no attention to Cain's gifts (cf. Gen. 4:3-5). This shows us that it is possible to do something good in the wrong way - that is to say, to do it negligently, or scornfully, or else not for God's sake but for some other purpose; and for this reason it is unacceptable to God.'
St. Symeon Metaphrastis
Remember we have to do things for God's sake, with a pure intention! And we have to pray for it, and pray for the work! And be thankful!
So that was why Cain's sacrifice was rejected. I often wondered why.
Everything we do should be done only and only for God's sake. No other reason is worthy.