Adam had two sons called Habil and Qabil. Adam thought that Habil, the younger son, should take over after him. But Qabil didn't like this idea and was very jealous. To settle the argument Adam thought of an idea. He told his sons to think of a present to give to Allah and to leave it on top of a certain hill.
The one whose present Allah accepted, would win the argument. Allah chose Habil's present because Habil had taken a lot of time and trouble to choose his present.