In the novella, Robert Neville was the last human survivor of a plague of vampires that's wiped out almost everyone on the planet, a plague that he himself is immune to for whatever unexplained reason. Every day he goes out into the ruins of the city (iirc it might have been LA or SF) to find the remaining vampires, stake them, drag them out into the sun and kill them. Every night they flock to his house and bang on the boarded-up windows and doors to try to get in and kill him, and he drinks until he passes out. This goes on for years, decades. Eventually he starts going to the library to learn basic research skills to try to cure the vampire virus, though largely out of boredom than any other reason. He wasn't a scientist in the book, but the guy he used to carpool to work with is the head vampire who leads the night assaults...but he can never find him during the day. Anyway, the whole point of the story is that he thinks he's a monster hunter killing vampires, or at the very most he's putting suffering plague victims out of their misery. He doesn't consider them sentient...but the twist is they are. The ones that have survived this long have adapted to the virus, and they're the new strain of humanity that will carry the species forward. He wasn't killing monsters, he was killing husbands, fathers, mothers, kids...he spent decades wiping out entire bloodlines by the thousands and never once did he ever feel bad about it. Eventually they manage to capture him and take him to the vampire city. As he's locked in a tower waiting execution, he looks out of the crowd of vampires all staring up at him in terror, and the last passage is something like: "As the vampire was the myth of the human, so now the human becomes the myth of the vampire. I was the monster that stalked the daylight. I will be the feared boogeyman mothers tell their kids about to scare them. I am legend." Neville = Devil. Get it?
That movie was a travesty to Richard Matheson. A sequel continues the bad ideas.