We don’t need to sleep, but our body will put us to sleep. There is no clear answer as to why we sleep. But one acceptable theory is our brain “understands” sleeping is going to help functioning. During sleep our immune system finally has the opportunity to clean up waste. The 2017 Nobel Prize winners for Medicine and Physiology discovered there are genes famously work as “inner clock”, and they think these genes are responsible for all the routines in our body.
But fundamentally we still do not have an absolute answer to why we sleep, just like we have several theories on why we dream. However, I believe whatever theories exist for why we sleep and why we dream, they are union of a bigger theory, not mutually exclusive.
[1]: https://www.google.com/amp/s/amp.theguardian.com/science/201...
[2]: https://www.nobelprize.org/nobel_prizes/medicine/laureates/2...