Why does the main function in Java reside in a class?
Probably for the same reason you put question marks at the end of a question: that's just how they decided it's done.
The main
method is the result of a convention that says "this is how the entry point's method signature should look" which doesn't exempt it from language semantics.
Java does not support methods outside of classes/interfaces and as such it has to be contained in one.