I present results from several years of concerted observations of the afterglows and host galaxies of gamma-ray bursts (GRBs), the most energetic explosions in the Universe. Short gamma-ray bursts originate from a wide variety of environments, including disk galaxies, elliptical galaxies, galaxy haloes, and intracluster and intergalactic space. Long gamma ray bursts associate almost exclusively with star-forming hosts, but the properties of these galaxies also vary widely. Some are hosted in extremely small galaxies, difficult to identify directly in emission or infer from the absorption of afterglow light, but the host luminosity distribution extends up to very luminous (>L*) systems as well. A significant fraction of long GRBs are observed along highly dust-obscured sightlines through their host medium. Some of these events are hosted within conspicuously dusty galaxies, although the hosts of other dust-obscured events show no outward signs of significant internal dust content. By measuring the wavelength dependence of dust absorption profiles using a few well-observed GRB afterglows, I provide evidence for ordinary dust with properties similar to those of dust in the Milky Way in a system at z~3, but a very different absorption profile from the dust in a galaxy at z~5, providing tentative evidence to support a transition in dust composition early in the history of the Universe. I present an observationally-determined redshift distribution for Swift GRBs, showing few to originate from high redshifts (z>5). I also provide the first photometric and spectroscopic catalogs from one of the largest GRB host-galaxy surveys ever conducted, including observations of almost 150 distinct GRB fields.