The story of Cain and Abel is fraught with "logical" problems because its setting has most likely been displaced at a certain stage of its development.
Part of the story functions as an etiology (a tale meant to explain the cause or origin) of the Qenite (or Cainite: Cain = Qain) semi-nomadic tribe which plays a very important role in Israelite history. This originally had nothing to do with the beginnings of mankind (compare the story of Lot's daughters for a similar etiology of the Moabites and Ammonites, in a later setting).
When this story was moved back to the origins of mankind, a number of logical problems artifically emerged (i.e. who might kill Cain, with whom would he marry?).
The farmer vs. shepherd (i.e. sedentary vs. nomadic, crop vs. flock) motif probably belongs to the original story (Abel's way of life being transferred on Cain as a curse) but once moved to the primeval setting it takes a much more general scope. Whence, probably, an additional oddity: the story now seems to provide the origin of sacrifices and at the same time takes them (and their scale of values, animal > vegetable) for granted.