Theory:

Nitrogen fixation:
What is the main component present in proteins, chlorophyll, nucleic acids and vitamins, which can only be obtained from the atmosphere? The answer is nitrogen. Animals get their nitrogen from plants. But, plants cannot get their nitrogen directly from the atmosphere. The air around us is a mixture of gases. Nitrogen is the most abundantly available of all these gases. However, in its gaseous state, nitrogen is useless to the vast majority of living things. With the help of certain microbes present in the soil, atmospheric nitrogen is converted into usable water-soluble form.
 
Rhizobium is one such kind of microbe. It is a bacteria that lives in the root nodules of leguminous plants, such as beans and peas, with which it has a symbiotic relationship. The atmospheric nitrogen gets fixed in the soil with the help of it.
Nitrogen fixation is the process of converting atmospheric nitrogen into nitrogenous compounds.
Nitrogen can be fixed by,

i) Lightning
ii) Nitrogen-fixing organisms present in the soil,
Example:
Rhizobium, Azotobacter and Blue-green algae like Nostoc
Now, you may be wondering, how the nitrogen quantity in the atmosphere remains constant with all the consumption by animals and plants?
 
Nitrogen occupies \(78\) % of the atmosphere and the reason for its balance in the atmosphere is due to its release back to the atmosphere. This sequence of events through which nitrogen is consumed by plants and animals and released back into the atmosphere is called as nitrogen cycle.
  
rhizjpg.jpg
Picture of a leguminous plant's root nodules
Nitrogen cycle:
Nitrogen cycle takes place in the following steps:
  1. The atmospheric nitrogen is fixed to be converted into usable compounds by bacteria like Rhizobiumand blue-green algae to increase the fertility of the soil.
  2. These compounds are utilised by plants through their root system. Nitrogen is used for the synthesis of plant proteins and other compounds.
  3. Animals feeding on these plants as food get these proteins and other nitrogen compounds.
  4. When these plants and animals die, certain bacteria and fungi convert these complex nitrogenous compounds present in their bodies into simple nitrogen compounds.
This process of releasing the nitrogen back into the atmosphere from the dead plants and animals by microorganisms is called, Denitrification.
Majority of microorganisms involved in the entire nitrogen cycle are bacteria. 
 
1024px-Nitrogen_Cycle_2.svg.png
Schematic representation of the flow of nitrogen through the ecosystem
Reference:
https://en.wikipedia.org/wiki/Nitrogen_cycle#/media/File:Nitrogen_Cycle_2.svg