The world’s population is getting older in what the United Nations calls an “irreversible global trend,” driven by longer lives and smaller families.