We present rest-frame near-IR (NIR) luminosities and stellar masses for a large and uniformly selected population of gamma-ray burst (GRB) host galaxies using deep Spitzer Space Telescope imaging of 119 targets from the Swift GRB Host Galaxy Legacy Survey spanning 0.03 < z < 6.3, and we determine the effects of galaxy evolution and chemical enrichment on the mass distribution of the GRB host population across cosmic history. We find a rapid increase in the characteristic NIR host luminosity between z ~ 0.5 and z ~ 1.5, but little variation between z ~ 1.5 and z ~ 5. Dust-obscured GRBs dominate the massive host population but are only rarely seen associated with low-mass hosts, indicating that massive star-forming galaxies are universally and (to some extent) homogeneously dusty at high redshift while low-mass star-forming galaxies retain little dust in their interstellar medium. Comparing our luminosity distributions with field surveys and measurements of the high-z mass–metallicity relation, our results have good consistency with a model in which the GRB rate per unit star formation is constant in galaxies with gas-phase metallicity below approximately the solar value but heavily suppressed in more metal-rich environments. This model also naturally explains the previously reported "excess" in the GRB rate beyond z gsim 2; metals stifle GRB production in most galaxies at z < 1.5 but have only minor impact at higher redshifts. The metallicity threshold we infer is much higher than predicted by single-star models and favors a binary progenitor. Our observations also constrain the fraction of cosmic star formation in low-mass galaxies undetectable to Spitzer to be small at z < 4.