Filesystem performance tends to degrade when you have tens of thousands of files in a single directory, so programs that manage thousands of files usually end up dividing them into many subdirectories. It's not just Firefox - git uses the same strategy, for example.