A dairy farmer's decision to cull or keep dairy cows is likely a complex decision based on animal health and farm management practices. The present paper investigated the relationship between cow longevity and animal health, and between longevity and farm investments, while controlling for farm-specific characteristics and animal management practices, by using Swedish dairy farm and production data for the period 2009 to 2018. We used the ordinary least square and unconditional quantile regression model to perform mean-based and heterogeneous-based analysis, respectively. Findings from the study indicate that, on average, animal health has a negative but insignificant effect on dairy herd longevity. This implies that culling is predominantly done for other reasons than poor health status. Investment in farm infrastructure has a positive and significant effect on dairy herd longevity. The investment in farm infrastructure creates room for new or superior recruitment heifers without the need to cull existing dairy cows. Production variables that prolong dairy cow longevity include higher milk yield and an extended calving interval. Findings from this study imply that the relatively short longevity of dairy cows in Sweden compared with some dairy producing countries is not a result of problems with health and welfare. Rather, dairy cow longevity in Sweden hinges on the farmers' investment decisions, farm-specific characteristics and animal management practices.The Swedish Government Research Council for Sustainable Development (FORMAS; Stockholm, Sweden).http://www.journals.elsevier.com/journal-of-dairy-sciencehj2023Agricultural Economics, Extension and Rural Developmen