"a reminder of death," 1590s, a decorative object, usually an ornament for the person, containing emblems of death or reminders of the fleetingness of life, common in 16c., a Latin phrase, literally "remember to die," that is, "remember that you must die." From second person singular imperative of meminisse "to remember, recollect, think of, bear in mind" (a reduplicated form, related to mens "mind," from PIE root *men- (1) "to think") + mori "to die" (from PIE root *mer- "to rub away, harm" (also "to die" and forming words referring to death and to beings subject to death).
in the figurative sense "wildly irresponsible person, potent person or thing freed from usual restraint," by 1896; in the literal sense an object of dread on old warships; the figurative use probably arose from a celebrated scene in a popular late novel by Victor Hugo:
You can reason with a bull dog, astonish a bull, fascinate a boa, frighten a tiger, soften a lion; no resource with such a monster as a loose cannon. You cannot kill it, it is dead; and at the same time it lives. It lives with a sinister life which comes from the infinite. It is moved by the ship, which is moved by the sea, which is moved by the wind. This exterminator is a plaything. [Victor Hugo, "Ninety Three," 1874]