Computers connect to IP addresses, not names, DNS is the internet's phonebook that turns one into the other. When you type a domain, your browser asks a DNS resolver (usually your ISP's, or a public one like 8.8.8.8) to find the IP.
On a first visit the resolver hunts: it asks a root server, which points to the .com servers, which point to the domain's own nameserver, and that one has the answer. The resolver caches the result, so the next lookup is instant. The whole hunt typically takes tens of milliseconds.