The story of Cain and Abel is a familiar one. Abel brings an approved sacrifice to God and is blessed. Cain brings an unacceptable sacrifice and is corrected by God. Seeing Cain's anger, God continues the conversation. "Sin is crouching at your door," He tells the older brother. "It desires to have you. But you can have mastery over it." Cain refuses to take mastery over his emotions, and instead takes mastery over Abel, committing the first murder.
It is interesting to notice that God assumes that Cain is able to make the right choice. He gives Cain more moral power than we often think we have. Cain is not portrayed as "enslaved" to his emotions, but rather as one who can take control of his passions. So why doesn't Cain "do the right thing?" I'm not sure we can know, but I'd like to hazard a guess that it's connected to desire.