"Then the Lord said to Cain, 'Why are you angry? Why is your face downcast? If you do what is right, will you not be accepted? But if you do not do what is right, sin is crouching at your door; it desires to have you, but you must master it.'" NIV translation
God knows our hearts and, here, we see that in Cain's heart was the fear of losing the place of the firstborn. God is telling him to get this under control or this sin will lead him into other sin.
"Now Cain said to his brother Abel, 'Let's go out to the field.' And while they were in the field, Cain attacked his brother Abel and killed him." NIV translation
Cain was worried about losing the place and inheritance of the firstborn son and so he killed his brother. God had urged him to do what was right and warned him about the downward spiral of sin but he had not listened.
The same type of thing happens to many people today as they start with what they consider to be a "small" sin and end up very far from God. This is due to the lack of understanding that all sin is detestable in God's sight and He does not have "small" sins.
"Then the Lord said to Cain, 'Where is your brother Abel?' 'I don't know,' he replied. 'Am I my brother's keeper?'" NIV translation
When confronted by his sin, Cain denied what he had done as if it could be hidden from God. That is the same thing that many people are trying to do today and hoping that they can get by and get to heaven based on their own righteousness.
"The Lord said, 'What have you done? Listen! Your brother's blood cries out to me from the ground.'" NIV translation
Just as his father and mother had done, Cain tried to hide from God what he had done. Cain did not realize that God already knew and was only asking the question to get him to realize what he had done. God does not need us to confess our sins to know what we have done. He wants us to confess our sins so that He may forgive and forget them.