The "M" stands for "Messier," and the number refers to the Messier catalog of comet-like objects. As explained in Starstruck Tonight:
In the late 18th century, Charles Messier (MESS-ee-ay) catalogued all the cloudy patches he could find in the sky so that he would not mistake them for comets.
A cloudy patch in Lyra was the 57th nebula listed in Messier's catalog. M57, now known as the Ring Nebula, appears like a little smoke ring peacefully wafting through the starry night. However, this doughnut of glowing hydrogen gas, speaks of the violent explosion of the outer layers of a once massive star. Near the center of the ring, only its hot bluish core remains intact.