Before the World Wide Web, there was still an Internet, and it was used for a variety of things: telnet, email, gopher, FTP, etc. At that time, it was traditional to assign domain name aliases to servers for common functions. So, smtp.example.com would be example.com's outbound email SMTP server, ftp.example.com would be example.com's FTP server, etc.
When the Web came along (early 1990's), it was just yet another application / protocol -- it wasn't necessarily envisioned at that time that it would be come the most popular thing to use the Internet for, next to email. So an organization's web server was assigned a domain name alias of "www." like any other service would have typically been assigned.
Over time many sites started dropping the "www.", because URLs are after all often typed in by people and yes it's 4 more characters than really necessary. But, "www." still lingers today and it's not likely to ever completely go away.