"I have to add my 2 cents.
The dog at the end survived, because the family the boy meets represents a sort of civility and possibly a return to a normal pre-disaster way of life-- at least in their minds. While everyone else was eating their pets, this family chose to take a "path of good". Also, the dog might be new to the group as well, and, when he arrived, the family was no longer in a
tribal community (as implied by the father's missing
Anyway... The whole movie is about the kid showing compassion and mercy to others-- regardless. From what others have said, this is an interpretation of a biblical story in which God helps the boy.
I don't know for sure, but it makes sense."