Habitat quality is a key indicator for assessing the biodiversity-maintenance functions of ecosystem services. The issue of habitat quality changes in semi-arid and arid areas has been becoming serious, but there are few deep investigations of habitat quality in these regions, such as studies of the temporal and spatial changes of habitat quality and its driving forces. This study focuses on the agro-pastoral ecotone of northern Shaanxi with vulnerable biodiversity. By using the Fragstats software, the InVEST model, and the Geo-detector model, we analyzed land-use data collected from 1990, 2000, 2010, and 2020, and we explored the landscape pattern index, the spatial and temporal variation of habitat quality, and the influence of its drivers. GDP, population density, precipitation, temperature, land use, NDVI, elevation, and slope were detected by Geo-detector. The research results show that: (1) Arable land and grassland were the dominant land types from 1990 to 2020, and there was significant mutual circulation between arable land and grassland. Forest area increased by 24%. Many other land-use types were transformed into construction land, and construction land increased by 727% compared with the base period. (2) Landscape heterogeneity increased in the study region, shown by the fractured structure of the overall landscape and by the aggravated human disturbance of the landscape. (3) Average habitat quality underwent a trend of oscillation. Regarding spatial distribution, habitat quality was higher in the east than in the west. (4) The influencing factors of habitat quality monitored by Geo-detectors show that the driving force of land use on habitat quality was the strongest, followed by precipitation and vegetation coverage. Elevation, slope, GDP, and population density had the least influence on habitat quality. The bi-factor interaction enhanced habitat quality to different levels. This study is critical to the conservation of biodiversity and to ecological civilization construction in arid and semi-arid regions.