keepong your cows all the time in stables, feeding them with grain, corn, fishmeal, whatever, purchased from cattle food giants + a good share of separately harvested grass for better ruminant digestion, is the most cost effective way to get meat and milk.
however the meat from grassfed, especially wild grasses with herbs, tastes better and has say 30% of the amount of fat, and fat of better quality in terms of health.
and butter from grassfed contains more carotenes (yellow), far more omega-3, some other health fatty acids.
So this can be sold at a premium price, limited by the market size for such premium quality.
all in all, the stable cows are dominating because of the lower production price, IF the farmer can get the capital for the higher investments needed, the size of the farm is big enough (now minimum 100 cows for milk cows, and treshold still increasing),
and local traditions do not hinder such a rationalised farming.