Under some situations, more productive habitats favor diversity. Usually some element of disturbance or competition is involved in maintaining high density gradients. At the same time, overall environmental stability is important in maintaining diverse communities. Other important factors are spatial heterogeneity, or environmental patchiness, endemism and genetic isolation. Competition and predation help to preserve species diversity by maintaining the number of individuals of various species below the carrying capacity.
Niches are a somewhat abstract concept defined in different ways.
The sum of the requirements of an organism. The role an organism plays in the ecosystem. In general, the more niches there are, the more species that can coexist in a particular area. Further, the more vertical and horizontal stratification that exists, the more habitats, niches, and possible species are possible. Temporal components can create more niches.