This thesis focuses on the effect of the environment of galaxies on their star formation activity and the metal content of their interstellar medium. I develop a technique to reconstruct the underlying number density field of galaxies in the Cosmic Assembly Near-infrared Deep Extragalactic Legacy Survey (CANDELS). I then use these measurements to estimate stellar mass and environmental quenching efficiencies out to z~ 3.5. I find that the environmental quenching efficiency increases with increasing stellar mass and decreasing redshift. I show that a dense environment can quench very massive galaxies as early as z~3. These observations provide a supporting argument for a scenario where the termination of cool gas accretion happens in a dense environment, and the galaxy starts to consume its remaining gas reservoir in depletion time. The depletion time is shorter for massive galaxies, so they are expected to become quenched faster. I also study the gas-phase metallicity of galaxies in different environments using near-IR spectroscopy of the MOSFIRE Deep Evolution Field (MOSDEF) survey. Based on gas-phase oxygen abundance computed from rest-frame optical emission lines, I find that at a fixed stellar mass, galaxies in overdense regions have lower metallicity than their field counterparts at z~ 2.3, but they become more metal-rich as they evolve to z~1.5. My results suggest that the efficient gas cooling mechanisms at high redshifts result in the prominent accretion of primordial metal-poor gas into the galaxies in overdensities. However, as galaxies evolve to the lower redshifts (z<2), the shock-heated gas in overdensities with massive halos cannot cool down efficiently, ramping up the gas-phase metallicity of galaxies. Future surveys will provide statistically significant samples of high redshift galaxies in diverse environments that can further test results from the present study. I build a machine learning model to transfer the knowledge gained in fields with a wealth of observations to those which lack such extensive observations. The technique provides valuable information to optimize the observing strategy for future surveys and offers complimentary data in the wavebands not accessible by these surveys.