[Al-Qur'an 5:27]: "And (O Muhammad SAW) recite to them (the Jews) the story of the two sons of Adam [Habil (Abel) and Qabil (Cain)] in truth; when each offered a sacrifice (to Allah), it was accepted from the one but not from the other. The latter said to the former: "I will surely kill you." The former said: "Verily, Allah accepts only from those who are Al-Muttaqun (the pious - see V. 2:2)."
As the children of Adam and Hawwa grew older, they were commanded to marry, establishing the union of family and the propagation of mankind.
Adam married one male from a set of twins to the female of another set, resulting in Qabil and Habil marrying the other set of twins.
It was said that Qabil had jealousy towards his brother because he desired to marry his own twin sister as she was more beautiful and he was older, but Habil refused to engage in the dispute with his brother.
According to the tafsir of Ibn Kathir, due to this dispute, Adam advised his sons to offer a sacrifice to Allah to resolve the dispute. Whoevers sacrifice was accepted, would be evidence that they were in the right. In ancient times, a fire would come from the heavens to accept a sacrifice. On this occasion Habil’s sacrifice was consumed and accepted by a fire, whilst Qabil’s was not.
According to THE PEOPLE OF THE BOOK (Ahlul-Kitaab), it was said due to Qabil’s arrogant manner, he refused to provide a sufficient sacrifice and had included some old wheat, that were from the worst crops he had grown, whilst Habil provided a ram.