Abel offered to God a more excellent sacrifice than Cain. See the account of Ge 4:1-5. Abel's faith was probably shown in offering just such a sacrifice as the Lord demanded, while Cain made an offering according to his own ideas.
By which he obtained witness that he was righteous, God testifying of his gifts. In some way the Lord testified his approval of Abel's sacrifice, and showed his disapproval of Cain's, perhaps by sending fire to consume Abel's.
And by it he being dead yet speaketh. By his faith. His faith speaks to all ages.