Dennis has explained the 3rd slash, needed to separate the
host from the
path, but the other two are much more interesting...
It turns out they were a useless and somewhat arbitrary addition to the URL syntax. Tim Berners-Lee, inventor of the World Wide Web and author of many of its standards (including the RFC that Dennis linked to), lamented his usage of the 'double slash' in an interview back in 2009.
The double slash, though a programming convention at the time, turned out to not be really necessary, Mr. Berners-Lee explained. Look at all the paper and trees, he said, that could have been saved if people had not had to write or type out those slashes on paper over the years — not to mention the human labor and time spent typing those two keystrokes countless millions of times in browser address boxes.
So, save for a minor (and uncharacteristic) lapse in foresight some 18 years ago, your file URL could just have easily been
file:/D:/Desktop/Book.pdf, rather than
There is, to answer your question, no good reason why URLs have 3 slashes.
Update: As @ComFreek points out in the comments, as of 2017, the
file:/D:/... example above is now valid! This is thanks to RFC 8089, which specifically calls out this fix from the previous standard...
According to the definition in [RFC1738], a file URL always started
with the token "file://", followed by an (optionally blank) host name
and a "/". The syntax given in Section 2 makes the entire authority
component, including the double slashes "//", optional.
What a time to be alive.