In leguminous plants,there occurs a change in the cytoplasm of roots which is responsible for production of Leghaemoglobin
These compound then forms the root nodules wherein dwells the nodule bacteria known as nitrogen fixing bacterias
Now these nitrogen fixing bacteria in root nodules fix the atmospheric nitrogen which is then converted into useful forms for plants ..
This is how the soil fertility is maintained…..
also
Leguminous plants like pea have nitrogen fixing bacteria RHIZOBIUM in their root nodules. This RHIZOBIUM coverts free atmospheric nitrogen in to nitrogen compounds which is then taken in by plants and some are left behind, the left behind nitrogen compounds increases the fertility of soil