As you noticed, the semi-colon is allowed but not necessary. I don't know why this is, maybe it was done to make life easier for C++ programmers switching to Java; in C++, the rules for semi-colons are slightly different.
It's not really a "class declaration with a semicolon", it's a "class declaration followed by an empty statement". Statements end with a semicolon, and statements can be empty strings.
But you can't put arbitrary statements outside a class declaration - it would be strange if you could put an empty statement outside a class declaration.