You do not really need a domain. So let me explain how the website hosting works. Once you have the website ready, you need to host it somewhere so that its accessible through the internet. Now, to make it accessible, you host on a webserver(on-prem or cloud). And you can finally access it using the server's IP. But these IP addresses are difficult to remember.
For example, google's website is hosted on the IP address: 188.8.131.52(this might be different for everybody as google might be using a load balancer.)
You can paste this IP on any browser's URL tab and it will redirect you to www.google.com.
But it's difficult for people to remember the IP addresses to access every website hence use the domain name.
A domain name is necessary if you want your clients/customer's to remember your website name.