Actually both marine and land hermit crabs find their first shells in the water. Generally a baby LHC that can't find a suitable shell before it comes ashore does not make it very far.
Marine hermit crabs live under water but, they can survive out of the water as well, providing it's not for an extended period of time. Their shellwater helps facilitate this.
I presume that LHCs evloved from species of marine hermit crabs that began coming ashore more and more (possibly because a shortage of food, maybe something else). Ones with mutated/modified gills were better able to breath atmospheric oxygen and survive on the shore. Eventually, the hermit crabs would have speciated. Now they are completely separate and have different traits, diets, and habitats.
The original, marine hermit crabs are still in the majority however. There are actually about 800 species of hermit crabs in the world. As we know, there are 12 (or 10 or 17, depending on how you count it) species of LHC. That leaves the rest of the 800 as MHCs.
