Irrigation and nitrogen application rates have significant effects on greenhouse tomato yields, as well as water and nitrogen use efficiencies, but little is known regarding how these rates affect plant–microbiome interactions and how the associated changes might impact tomato yields. In this greenhouse study conducted over two years, the effects of three irrigation levels (moderate deficit with 65–75% water holding capacity threshold, slight deficit with 75–85%, and sufficient irrigation with 85–95%) and four nitrogen application levels (60, 120, 240, and 360 kg ha−1) on tomato growth, yield, water and nitrogen productivities, and rhizosphere microbial diversities and functions were investigated. The results demonstrated that the highest tomato leaf area, dry biomass, yield, and water and nitrogen productivities were obtained under the treatment with sufficient irrigation. With increasing nitrogen application, the tomato leaf area, dry biomass, yield, and water and nitrogen productivities showed a trend of first increasing and then decreasing. Overall, the treatment (N2W3) with sufficient irrigation and 240 kg ha−1 N was associated with the highest tomato growth, yield, and water and nitrogen productivities. Moreover, optimal irrigation and nitrogen application obviously altered the structures of rhizosphere bacterial and fungal communities, particularly recruiting microbiota conferring benefits to tomato growth and nitrogen fixation—namely, Lysobacter and Bradyrhizobium. Ultimately, optimal irrigation and nitrogen application significantly increased the relative abundances of functions related to carbon, sulfur, and nitrogen metabolism, especially nitrogen fixation. In summary, optimal irrigation and fertilization enhanced tomato yield, as well as water and nitrogen productivities by increasing the nitrogen fixation functions of the rhizosphere microbiome. Our results provide significant implications for tomato cultivation in greenhouses, in terms of optimized irrigation and fertilization.