First, this applies only to public classes; package-private classes can go into files of any name. For public classes this is a convention, along the same lines as the placement of files in directories that mirror the structure of your packages, and using .java
extension.
This is done so that Java compiler can find classes without examining all Java files in the folder.
Note that the convention does not need to be universal: Java supplies a standard that is available to anyone to implement, so one could build a system where Java source files are placed in a database or in a cloud instead of a regular file system. Developers of this Java implementation could theoretically come up with a different convention altogether, or not use any conventions at all.