If you don't use power or trickle filters for the tank then you use live rock and live sand to filter the water, rock more than sand. The live rock has beneficial bacteria living on and in it and this bacteria breaks down the ammonia produced by the fish waste and food. If you have a filter on the tank then you don't need rock other than for decoration and for the fish to feel comfortable and secure.
If you use live rock for the filter, then you need to have lots of water moving around the rock. This is done with a couple of water pumps/ powerheads.
Live sand is often used to help break down nitrates. If you have a thick (4-5inch) layer of sand then the bottom few inches becomes anaerobic (lacking oxygen). The anaerobic conditions encourage bacteria that eat nitrates and convert them into nitrogen gas, which can be expelled from the tank through normal gas exchange at the water surface.
Crabs like rock to hide in and crawl around on looking for food.