D&D from the start was strongly inspired by pure heroic fantasy writers like Michael Moorcock.
Moorcock, a pure heroic fantasy writer? Definitely not in the sense you mean it. The genre he wrote is nominally heroic fantasy, but Elric of Melniboné of the Elric saga - maybe his most famous creation - is almost the prototypical anti-hero.
As for why it is interesting to play such characters, or even darker ones: why do people play games? To experiment. To learn about things through play what for real might be too dangerous. What is it like to be a person who does the darker things. What might bring people to go down the darker paths? What might tempt me to do the same? And of course, sometimes it's just for katharsis, because it's so satisfying to step away from the constraints of our society for a time, even though only in your imagination, and go and just kill them all.