That seems to be the thesis of this paper by neurobiologist Jerome Siegel:
Sleep can be seen as an adaptive state that benefits animals by increasing the efficiency of their activity. It does this by suppressing activity at times that have maximal predator risk and minimal opportunity for efficiently meeting vital needs, and by permitting activity at times of maximal food and prey availability and minimal predator risk.
I read this as arguing that if an animal is not sleeping it will do things that are not in its interest. So sleep stops it from doing those things. Of course natural selection could instead have simply taught the animal not to do what’s against its self interest but instead, under this theory, sleep acts like a commitment device to blunt a self-control problem.