The beneficial bacteria makes up the nitrogen cycle. Food, fish waste (poo, urine), dead things, all decay and turn into ammonia. There is one bacteria that turns the ammonia into nitrites. There is another bacterial that turns nitrites into nitrates. There is an additional bacterial or organism (such as macro algae, Chaeto for instance) that will turn nitrates into nitrogen gas which is then expelled into the air.
Ammonia and nitrites can quickly kill living things, such as fish and corals. Nitrates, in low quantities are tolerated by the living things, but most of them prefer zero nitrates. Other corals, seem to thrive in "dirty water".
When live rock is first purchased, it typically needs to be "cycled". This means placing it in salt water and letting the beneficial bacteria get established. This process can be measured and observed by testing for ammonia, nitrites, and nitrates. You would usually see a spike in ammonia with little or no nitrites and nitrates. Then ammonia would drop and the nitrites would spike. Once again, typically little or no nitrates. Then the nitrites will drop and nitrates will rise. In a new tank, about the only way to get rid of the nitrates is through water changes.
During the cycle, we try to not let ammonia and nitrites get too high because it can kill other live things that came on the rock. We control the toxic levels by performing water changes. The cycle usually takes 4-6 weeks to complete. Now you are ready to SLOWLY add other live things, such as fish. We do it slowly so the bacterias can reproduce and expand to keep up with the additional biological load. After adding the first fish, it's recommended to wait about 4 weeks before adding another one.
I'm sure I missed a whole lot of stuff, but that's it in a nutshell.