A hermit crab's environment is the most crucial part of their lives. If the environment is not right, they'll have a hard time surviving. Think polar bar in the Amazon, it just doesn't work. Hermit crabs come from hot, humid islands and beaches of the Carribean Sea. Their cage is very different from their island homes. It is your responsibility to try and recreate this habitat as closely as possible.
Get a nice cage. The best type of cage is glass or plastic, since these trap and hold heat and moisture much more efficiently than any other cage. You can never buy "too big" of a cage. The size depends on the number of crabs and their sizes that you are keeping. The more room, the better. Don't keep too many in one cage, they gang up on eachother (usually the smaller ones) and kill or injure them. It is recommended to keep only 6 at most to every ten gallon aquarium (or the equivalent). I keep 3-4 in a five gallon aquarium comfortably.

To recreate the heat of their jungle homes, all you have to do is put a lamp over or very near the cage. For the crab to live, the temperature must be between 67 and 85 degrees. They can survive below this, but they will not be active at all. Too far below 67 and they will die. At night, keep the cage dark. Turn off the lamp and let the heat trapped in the cage stay. Hermit crabs are very nocturnal, and this is when they will be most active.

Keep the cage very humid. Keep a lot of water in the cage (none too deep that the crab drowns). Keep the sponge and water dish full and wet to provide adequate humidity.

Cover the bottom of the cage with something like sand or aquarium gravel. Make sure the gravel is very small, if it's too big the crab can't burrow and won't like it. Natural colors keep the crab healthier, flourescent colors tend to make them inactive. If you get rocks or sand from the wild, be sure to boil it for 10 minutes to make sure it is sterile before adding it to the cage. Some people keep a mineral called dolomite in the cage on the assumption it keeps a crab healthier. I have heard arguments both ways on this issue. I don't keep dolomite in my cages simply because I can't find any at my local pet stores.

Keep many new shells in the tank that are bigger than they ones your crab already has. As they grow, they'll need bigger shells. See the Shell section for more on this. 1