Popular belief says the phrase originated in ancient Rome: as a Roman general was parading through the streets during a victory triumph, standing behind him was his slave, tasked with reminding the general that, although at his peak today, tomorrow he could fall, or — more likely — be brought down. The servant is thought to have conveyed this with the warning, "Memento mori".wiki
It is further possible that the servant may have instead advised, "Respice post te! Hominem te esse memento! Memento mori!": "Look behind you! Remember that you are a man! Remember that you'll die!", as noted by Tertullian in his Apologeticus.