I have noticed many times like if a person says to someone that one of my relative passed  

away the other person replies **Sorry to hear that**   

I don't get the meaning of this reply. Sorry is used for forgiveness or when someone has done  

a mistake and he promises not to do it again. Is this a correct sentence ?   

Is there any better reply than this?