Other answers point out that in the story, the men go inside the Moon. However, in addition to that, I believe the use of 'on' for celestial bodies wasn't so well established in 1900 when the story was written, with 'in' being an acceptable alternative.
In his previous book, the War of the Worlds (1898), H. G. Wells uses both "in Mars" and "on Mars". ("On Mars" appears 5 times, "upon Mars" 5 times and "in Mars" 3 times, at least in the version on project Guttenberg.) For example, in chapter 3 he writes "In spite of Ogilvy, I still believed that there were men in Mars." So I think for Wells at that time, "in the Moon" would have been synonymous with "on the Moon" and didn't necessarily have to refer to being inside the Moon.
Indeed, in The First Men in the Moon itself, Wells uses the phrase "in the Moon" before the men are taken inside the Moon. (In chapter XI: "It filled me with a curiously benevolent satisfaction that there was such good food in the moon." They are still on the surface at this point.)
As further evidence I present Google ngrams for "in Mars", "on Mars", "in Venus", "on Venus", "in the Moon", "on the Moon":
The Moon ones are a bit conflated because "in the Moon" appears in the phrase "man in the Moon", which is why I included the others as well. You can see that initially the "in" and "on" forms both occur, with the "on" forms not really taking over until around the 1950s, when spaceflight started to become a thing.
Clicking through for examples, one finds plenty of sentences like "...the work of an intelligent race, if any such race could possibly have been developed under the adverse conditions which exist in Mars" or "fogs and mists prevail in Mars," so "in" does refer to the surface, at least some of the time. I suspect people thought of being "in" a planet as similar to being in a country.
One can also find several other books from 1900 or before that include "in the Moon" in their title, including The Man in the Moone (1638), which features a man who lands on the Moon but doesn't go inside it, as well as The Marvellous and Incredible Adventures of Charles Thunderbolt, in the Moon (1851) and Adventures in the Moon And Other Worlds (1836). (I haven't checked to see if the characters in the other two books go inside the Moon or not but suspect they don't.)
So in summary, I suspect that to a reader in 1900 "the first men in the Moon" wouldn't have sounded odd and would have meant the same as "the first men on the Moon".
However, by 1964 when the movie came out the language had changed a bit and "in" would have been seen as referring specifically to the interior, which is presumably why the movie poster in Valorum's answer emphasises that aspect so strongly.