"Now Adam knew Eve his wife, and she conceived and bore Cain, and said, 'I have acquired a man from the LORD.' Then she bore again, this time his brother Abel. 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. And Cain was very angry, and his countenance fell. So the LORD said to Cain, 'Why are you angry? And why has your countenance fallen? If you do well, will you not be accepted? And if you do not do well, sin lies at the door. And its desire is for you, but you should rule over it.' Now Cain talked with Abel his brother; and it came to pass, when they were in the field, that Cain rose up against Abel his brother and killed him" (Gen. 4:1-8).
To state that Adam "knew" his wife is a euphemistic reference for sexual relations. Many children are born to Adam and Eve, starting with two sons (Cain and Abel). We learn from 5:3 that Adam was 130 years old when the third son, Seth, was born (and Abel is already dead at this time; cf. 4:25). Although no daughters are mentioned by name, Eve ("the mother of all living" - 3:20) must have had some daughters to supply a wife for Cain and perhaps her other sons.
Cain and Abel pursue different lines of work (as a farmer and shepherd, respectively), though both were honorable endeavors. Some, who think that God will accept anything offered to Him as a gift, are confused by God's rejection of Cain's offering. Why was the animal offering of Abel acceptable but not the grain offering of Cain? We can know with certainty that God gave prior instructions regarding what constituted an acceptable offering here--the details of which are not recorded in the text. We can know this because of Hebrews 11:4, where we learn that Abel acted here "by faith." It is impossible to act by faith where God's word has not first been heard (cf. Rom. 10:17). So, Abel obeyed God's instructions and Cain didn't. There are two possibilities regarding the error of Cain here (and they are not mutually exclusive): Either (1) God required an animal offering and Cain brought grain or (2) God required that an offering that is brought be the best one has to offer (i.e., the first-fruit or firstborn). It should also be noted that there is nothing in the text that indicates whether or not this is the first offering either of these men had made. The fact that God did not respect Cain's offering makes him "very angry, and his countenance fell." He's very upset on the inside and it is showing on the outside as well! The proud and arrogant often become enraged quickly. God, who knows the hearts of men, is aware of the temptations churning through Cain's mind. Adam's firstborn son is contemplating wicked behavior, and God warns him (cf. Eph. 4:26). If we do not rule over temptations, they will rule us! Cain is a tragic example of this. When an opportune time comes, he takes out his frustrations upon his brother in an exceedingly immoral way--murder! He should have controlled himself; he could have controlled himself. He will suffer greatly for this sin.