When Cain and Abel offer sacrifices in Genesis 4, it doesn't seem to be the first time that they made an offering. They seem to know what God expected of them. Why don't we have any background in Scripture on what happened prior to this occurrence?
While we don’t have a complete picture from Scripture, we do have enough information to help us make some logical assumptions. While Cain and Abel's offering in Genesis 4 appears with no explicit explanation as to why the offering is being made, we do have other Scriptures to help us understand.
First, we know this wasn't the first offering recorded in Scripture, The very first offering was made in Genesis 3:21, when God made clothes of animal skin for Adam and Eve to cover their nakedness. Using animal skins means animals were killed, most likely as a sacrifice for the sin in the Garden. This offering also foreshadowed Christ’s offering, whose righteousness covers our sin (Romans 4:3-8). In both cases, blood was shed, because the shedding of blood is necessary for the forgiveness of sins (Hebrews 9:22).
The fact that God made an offering for Adam and Eve's sin and that Abel and Cain are making offerings that include at least one animal's death allows us to assume that God had instructed Adam and Eve to make such offerings going forward, and they naturally passed that instruction on to their children.
In fact, it only makes sense to assume God instructed man concerning sacrifices, otherwise how God could be said to be pleased or displeased with Abel and Cain's offerings? While the heart of the one offering is ultimately most important, we know from later Scripture that the manner of our offerings us also important to God.
So, while it’s possible (and even likely) that this is not the first human offering made, this was the moment in which God decided to confront Cain’s unbelief. In our Genesis teaching, both Abel and Cain offered more than one thing, so God was not displeased with the manner of Cain's offering but with his heart, that is his lack of faith.
As we read in Hebrews 11:4-6:
By faith Abel offered to God a better sacrifice than Cain, through which he obtained the testimony that he was righteous, God testifying about his gifts, and through faith, though he is dead, he still speaks….And without faith it is impossible to please Him, for he who comes to God must believe that He is and that He is a rewarder of those who seek Him.
Therefore, we thank God for the only offering that truly saves, His Son, Jesus Christ.