So for plants to grow, useful nitrogen must be constantly replenished. This useful nitrogen comes ultimately from the atmosphere, which is 78 percent nitrogen gas. But nitrogen gas, which contains two nitrogen atoms bound to each other, is too stable to transform easily into the reactive forms that plants can use. Fixation involves splitting the paired nitrogen molecules apart and converting each into ammonia, a more chemically reactive compound. This process requires an enormous amount of energy.
Some nitrogen is fixed by lightning and ultraviolet rays.
But 80-90 percent of fixed nitrogen was originally put in the soil by one of the roughly 100 species of bacteria that can fix nitrogen gas by using the energy they get from the other nutrients they feed on. But since there is usually a limited amount of these other nutrients, the amount of fixed nitrogen these bacteria produce is relatively small. Then there are the rhizobia. By themselves, rhizobia are like many other soil microorganisms, searching for nutrients and growing slowly, very frugal in their metabolism. Rhizobia invade the legume roots, and the infected roots subsequently develop growths called nodules that house the bacteria, whereupon the bacteria start fixing nitrogen for the plant.