First you must register your domainname with a suitable registrar.
As part of this the IP addresses of 2 computers that will serve as "DNS servers" are required. Many registrars provide these servers as part of the service.
Next the "DNS zone files" on those "DNS Servers" need to be updated to include a reference that basically says "www.mydomain.com is at IP address 123.321.123.321"
Again most registrars provide an easy way to do this.
The computer with IP address 123.321.123.321 must be on the internet and running a web server that can respond to requests.
Then when someone types in www.mydomain.com, their local DNS system looks up the zone file (or a locally cached copy their ISP has) and this tells them the 123.321.123.321 IP address. The web browser then sends a "give me this web page" message directly to that IP address. Which then sends them back the web page.