Just because of how heartless he seems to everyone else, people tend to forget what he has to live with. Snape had to watch his mortal enemy marry the woman he loved, agree to be Dumbledore's spy, only for her to be killed later. In Harry's case, he had to look into Lily's eyes for years, and be reminded of his father. Then when he learns that Harry must die, he feels the need to take care of Lily's son. Makes you realize what he had to go through, and in the end suffer a painful death. He is truly a hero, and showed everyone that all Slytherins are not bad.