Sustainable agriculture

Why can a legume in a crop rotation contribute nitrogen to the farming system?