And here you have the case of Abel who understands that he's a sinner, and he understands that he needs forgiveness, and he understands that there must be an atonement and blood must be shed. And so he makes the symbolic sacrifice clearly in accordance with an instruction given to him by God and he did it by faith.
There are broadly two possible ways of looking at this. The traditional way (which we follow here) is to assume that God had given clear instructions for an offering, and that the offering was specifically designated as an animal offering, a burnt sacrifice, and blood was to be shed, and this would symbolise an atonement for sin. This view is in line, of course, with what God later did when he established worship for the children of Israel. and so that is a natural thing to think. In that case the problem with Cain was that he disobeyed the instructions, which reflected his heart, and he wanted to show off and to bring to God something of his own work, his own prowess. He did not need an atonement. Another way of looking at it is simply to say that, in the case of Abel, he was sincere in his love for God. He came to him as a sinner, realising that only by grace could the human race be received at all. Abel sought to live for God and to trust in him, and so he and his offering of thanksgiving was accepted, whereas Cain was the opposite, and so he was rejected. We cannot be absolutely certain which of these two views is correct. Hebrews 11 tells us that the reason Abel was accepted and Cain rejected is that Abel offered his gift by faith, and Cain did not. This might imply that Abel obeyed a clear instruction to bring an animal sacrifice representing the atonement, but Cain was not going to go to Abel and obtain an animal for a sacrifice. But equally it could mean that Abel offered his gift, trusting in God, and recognising that his gift could not purchase God’s favour. But Cain came proudly and his heart was not right before God.