Personally I agree with Marcus Schmidt and his idea of "energy allocation function of sleep". Basically it says that distinct physiological states provide viable configurations of priorities for vital functions that allow for the lowest possible energy expenditure over the whole cycle. I.e. there's no single specific function of REM sleep, it hosts all functions that are too costly to prioritize during other states, and the same is true for NREM.