And to add a bit more interesting history (having been involved personally pre www days (80's)):
ARPANET was a project of (D)ARDPA - Defence Advanced Research Projects Agency which was focussed on developing reliable communications over disparate and unreliable data communications networks. This was the genesis of TCP/IP (IP "Internet Protocol" being the connectionless unreliable network layer) with TCP being the connection based, error correcting transport layer (Transmission Control Protocol).
Translating IP addresses into human readable names became important for usability, thus further up the network protocol stack came in DNS (Domain Name Service) that translated names to IP addresses (rather than relying only on the aforementioned hosts file on each machine).
In the beginning, there was really only .mil .edu and .gov TLDs. .com came along primarily for defence and government contractors. Most early usage was email, ftp and newsgroups (UUNET being another offshoot). gopher (gopher://) preceded http and was terminal text based hyperlinking. Basically http without graphics.
In Australia (where my involvement started), we had AARNET - Australian Academic and Research Network.
Separation of the domain name address space (and mapping to class A, B, C IP address ranges - 255.0.0.0 / 255.255.0.0 / 255.255.255.0) was an issue with ARAPNET (now beginning to be called the internet) spreading beyond its U.S. only birthplace.
So by various conventions (agreed through the RFC process) country abbreviations got added. So here we had .gov.au .edu.au .com.au. And to start with, that was about it.
A side note on RFC "Request for Comments" - was originally a very engineering focussed comment forum for further development of internet protocols. Its now become the standards body, with all the overwhelming formality and verbosity of any "standards" organisation. A quick read of the early RFCs is refreshing. For the really authoritative answer to this SE question have a read of: https://www.ietf.org/rfc/rfc1034.txt
So though the original motivation for dotted domain names was technical, certainly with the .com and .com.xx names, these have in later years become in embroiled in legalities of trade practices, commercial trademarks, et al, to the extent that its become impossible to both serve the technical / organisational objectives of a name space, and the commercial and geopolitical influences on the reservation of names (not to mention the parasites of domain name squatters who've made $billions over the years just for exploiting a dictionary and making it hard for people and organisations with real and actual purposes to have particular names).
So the coming of new TLDs is a welcome thing. It in effect deregulates some of the congestion that’s been tied up with lawyers and bureaucracies for a long time.
Why not in a single name space? (ie http://name/resource/resource).
Who owns the name?
And who owns the name in different countries which operate under different legal rules?
My surname could easily be McDonald......