The factors limiting the habitat range of species are crucial in understanding their biodiversity and response to environmental change. Yet the genetic and genomic architectures that produce genetic variation to enable environmental adaptation have remained poorly understood. Here we show that the proportion of duplicated genes (P(D)) in the whole genomes of fully sequenced Drosophila species is significantly correlated with environmental variability within the habitats measured by the climatic envelope and habitat diversity. Furthermore, species with a low P(D) tend to lose the duplicated genes owing to their faster evolution. These results indicate that the rapid relaxation of functional constraints on duplicated genes resulted in a low P(D) for species with lower habitat diversity, and suggest that the maintenance of duplicated genes gives organisms an ecological advantage during evolution. We therefore propose that the P(D) in a genome is related to adaptation to environmental variation.