The conflict between adaptation and dispersal for maintaining biodiversity in changing environments