The most commonly accepted theory for how R.E.M. got their name is that Stipe picked R.E.M. at random from the dictionary. In this context, R.E.M. stands for rapid eye movement, or the point in sleep when eye movement continues although the brain picks up no visual signals. During REM sleep there’s some brain activity, and this is also when dreaming most often happens, as WebMD explains.
As American Songwriter notes, R.E.M. was not the first name the band considered, one of which was Twisted Kites. Dr. William Dement, the scientist who first used the term REM sleep (with no periods, as the sleep science term is often stylized, via The New York Times) even reached out to the band once they became successful. At that point, Stipe allegedly denied that his band R.E.M., periods included, derived their name from the sleep stage, after all, which casts this first version of the band name’s origin story in doubt.