He gave harry a memory of dumbledore telling him to kill dumbledore because he was struck by a curse and the other contents proving that he was against voldermort and that he was trying to protect harry.
dumbledore told him to kill him to save him from a slow horrible death and to help their plan to work. snape loved harry's mother and so hated voldermort for killing her and was woring as a double agent against him. it turned out snape was brave and crucial to voldemort's downfall. did u even read it?