The relationships between rhizobium bacteria and the legumes are mutualistic relationships where the legumes provide the bacteria shelter in special root nodules, and the bacteria help the legumes form important nitrogen compounds. The bacteria and the plants work together to activate special genes and create necessary proteins and other compounds.
Peas, beans, clover and alfalfa are all legumes with the ability to form relationships with rhizobium bacteria. This relationship is very useful for agriculture, since legumes can be grown without the need for nitrogen fertilizers. This process often leaves enough nitrogen in the soil that other types of plants can later benefit, which removes the need for fertilizers even when rotating non-legume crops into the same spaces.
The bacteria fix atmospheric nitrogen into usable forms, but they can only do so in partnership with legumes. Rhizobia are the only type of bacteria to form this relationship. As the legumes grow, their roots release compounds which signal their presence to bacteria in the soil.
The bacteria, in turn, release compounds that stimulate the roots to form unusual root hairs with tubes for the bacteria to enter. These tubes are known as infection threads. It is only when the bacteria are established in the roots that nodules are formed.