In Death Note Rem liked Misa so much, or maybe he was in love with her. He wrote L's name in the Death Note and killed L because he was protecting Misa and he knew he will die soon after doing so.
But I just wonder: why didn't he instead tell L's real name to Light Yagami or Misa, so they could write L's name in their Death Note and kill him themselves?