With the rapid development of the digital economy, understanding the relationship between the digital economy and the environment is increasingly important for sustainable development. This study mainly studies the nexus of digital economy development and environmental quality for 217 cities in China from 2003 to 2018. Specifically, this study first evaluates the degree of coupling coordination between the digital economy system and the environmental system. Results show that the coupling coordination degree between the digital economy system and the environmental system shows a fluctuating rise from 2003 to 2018. Furthermore, this study empirically investigates the impact of digital economy development on PM2.5, which represents environmental quality, and results show that digital economy development significantly reduces PM2.5. The above finding is still valid by using the quasi-natural experiment of broadband China for the robustness test. Urbanization, population density, and economic development have caused threshold effects. When the urbanization rate and population density exceed a certain threshold, the digital economy significantly inhibits PM2.5. In contrast, when the per capita GDP exceeds a certain threshold, the digital economy significantly promotes PM2.5. The digital economy mainly affects pollutant emissions through direct and technological effects.