In some filesystems it also makes retrieving the file faster, as the file system doesn't have to search through quite so many directory entries to find the one that is requested (it's easier to find one file in a directory of twenty than it is to find one file in a directory of twenty thousand).
Of course, there is also the possibility that there aren't any directories called 2, 3, d, or whatever (and maybe not even a file called 2d39981005.jpg). There is no requirement that URLs supplied to the web server have to bear any sort of resemblance to filepaths used by the filesystem. I doubt that this is the situation here, as unless the 2, 3, d, have some sort of significance to site navigation then the URL is excessively complicated; but "URL rewriting" is a standard technique of making URLs fit the requirements of the site instead of the particular backend technology being used.