If the niches (or functional roles) of 2 species in an ecosystem are identical, then one of them will go extinct. This is known as the competitive exclusion principle and was demonstrated by Gause's experiment with Paramecia. When grown in isolation, the two species that he used followed the normal growth curve, eventually each reaching their carrying capacity. However, when both were grown in a test tube together, one always outcompeted the other so that one species survived and the other went extinct in the tube. Whether the surviving species was P. aurelia or P. caudatum depended on the environmental conditions within the test tube. This occurs in nature as well because two species with overlapping niches are going to be in competition for all of their resources including food and space.
Competitive exclusion does not always occur, however. Niche partitioning can allow similar species to coexist within a particular environment. This allows coexistence of species with similar niches because, when it occurs, the realized niche is smaller than the fundamental niche for each species allowing them to divide the resource. For example, if there are similar species of bird and their fundamental niche involves utilization of an entire tree, niche partitioning allows them to coexist if the realized niche of each species is now a smaller portion of the tree so that there is minimal overlap between these realized niches.
The link provided goes to a website with figures showing both situations.