There are plenty of examples for why you would sacrifice yourself to save others.
1. You know from movies/TV/media that those who sacrifice themselves are considered heroes. If at the moment when you are making the decision to sacrifice yourself you think of being a hero, then you sacrifice yourself.
2. You have some sort of emotional connection between the person you are saving, so you sacrifice yourself because you have so much love for the person that you cannot imagine living without them, or you cannot imagine having to bear the pain of their death.
3. You know that the person you are saving will go on to live a great life and accomplish greater things than you would. You admire this person, and because you think highly of this person, you want him/her to feel the same way. You sacrifice yourself because you know that person who will go on to do great things will always remember you/speak of you.
These are some of the countless examples.
Also, you mentioned the desire to do good. Is that not in your rational self-interest? Your desire to do good IS your self-interest, and if it means sacrificing yourself, then that IS the action of self interest.