An ecosystem works on continuous Interaction and Interdependencies among various components. All the living beings depend on various abiotic factors to obtain raw material and energy. Producers depend on soil, air and sunlight to produce food. Primary consumers depend on producers for food. Secondary consumers depend on primary consumers for food. Now let us consider following scenario.
Imagine two herbivores A and B. Animal A can feed on a variety of plants, while animal B can feed on only one plant. If the sole plant which is eaten by animal B is somehow wiped out from the area, then animal B will also face extinction. But loss of a few plant species will not pose any danger to the existence of animal A. This shows the advantage of diversity in terms of available plants for animal A.
The above logic applies to other organisms as well. This means that if there is rich biodiversity in the ecosystem, then primary and secondary productivity is at optimum level. This helps in maintaining stability in the ecosystem.