This is said to a person, whom have lost someone in their lives. This gives a comfort to the person.
This can also be said to someone, whom have lost a female companion, but with a swift of the "he" to a "she"
Walking towards my friend who just lost his mother at the graveyard. I walked to him and said: "god rest his soul"
Or at the hospital of a newly death and comforting the depressed friend: "god rest he/her soul"