I would say he is trying to tell us that anonymity awaits everyone in death, but Heaven is a comfort.
The poet is walking around a cemetery and looking at the tombstones, imagining what those people were like while they were alive. In the end, he concludes that it doesn't really matter because they are dead, and everyone dies, and will be the same in Heaven, which he finds comforting.