This is on the basis of clustering/pattern matching body movement, body temperature, and some brain wave/MRI crap.
VERY broadly speaking, "deep" NREM stages are important for "body health" while REM is important for maintenence of memories and "mental health".
As with anything in neurobiology, it's "emerging evidence suggests that..." and nobody really knows what's going on. Except all evidence suggests sleeping less is bad for pretty much everything.
The dynamics of sleep state transitions are also pretty meaningful, e.g. time it takes to move from one stage to the next, whether there's "backwards" transitions, etc. For example, sleep deprivation lengthens deep NREM time, lowers latency from wake -> NREM I, and shortens the entire sleep cycle.