Microbial genomes encode functional repertoire of microbes. However, microbes rely on various proteins to be expressed to carry out specific functions, and the expression of those proteins can be affected by the environment. It remains elusive how the selective expression of a protein depends on whether it is metabolically essential to the microbe's growth, or it can claim resources as an ecological niche. Here we show that by pairing metagenomics and metaproteomics data we can reveal whether a protein is relevant for occupying ecological niches or is essential for microbial metabolism. In particular, we developed a computational pipeline based on the quantification of the gene-level (or protein-level) functional redundancy of each protein, which measures the degree to which phylogenetically unrelated taxa can express (or have already expressed) the same protein, respectively. We validated this pipeline using both simulated data of a consumer-resource model and real data of human gut microbiome samples. Furthermore, for the real data, we showed that the metabolic and ecological roles of ABC-type transporters and ribosomal proteins predicted by our pipeline agree well with prior knowledge. Finally, we performed in vitro culture of a human gut microbiome sample and investigated how oversupplying various sugars involved in ecological niches influences the community structure and protein expression. The presented results help us identify metabolic and ecological roles of proteins, which will inform the design of nutrient interventions to modulate the human microbiome.