Biodiversity has always been defined as merely being the number of species in an ecosystem. Such a simple definition belies the complexity of factors that are involved in achieving biodiverse ecosystems. While abiotic factors (mainly climate) have obvious influences, more complex is the interplay between the various biotic factors and how they influence each other. In response to a reader question, I identified the two of the latter category that I consider the most important.
The first is the species that have a disproportionate effect on their ecosystem, by affecting things like nutrient cycling, habitat structure and density, microclimatic conditions, primary and secondary production, etc. These are the keystone species, dominant species and ecosystem engineers. As an easy example, imagine an estuary: one that is dominated by macroalgae (and thus most likely eutrophic) will support much less animals than a seagrass-dominated estuary (Deegan et al., 2002). So in an estuary, biodiversity is determined by the main primary producer present, the dominant species.
To stick with this example, why is the seagrass species so important? For this specific example, there is the plain fact that seagrass does not cause eutophication and keeps the water-column oxygenated. But a deeper ecological aspect that can be applied to all ecosystems is the cascade of interactions typical in ecosystems; for this example specifically, you have fish and sea urchins feeding on the seagrass and stemming their growth, giving their competitors an upper edge. On the other hand, you have gastropods and crustaceans who feed on seagrass competitors and thus help the seagrass preserve their dominance. Refer to Duffy et al. (2003) for details. So competition is the key to maintaining biodiversity, even if that does sound somewhat paradoxical, and this is a pattern we notice in all other ecosystems as well.
Of course, there are other factors, but these are, in my opinion, the only two that are applicable regardless of the ecosystem. If you think I got it wrong, chastise me in the comments or by e-mail.
Deegan LA, Wright A, Ayvazian SG, Finn JT, Golden H, Merson RR & Harrison J. 2002. Nitrogen loading alters seagrass ecosystem structure and support of higher trophic levels. Marine and Freshwater Ecosystems 12, 193–212
Duffy JE, Canuel EA & Richardson JP. 2003. Grazer diversity and ecosystem functioning in seagrass beds. Ecology Letters 6, 1–9.