The idiom is understood to mean that something will take an indefinitely long time based on cows being known to make their way at an unhurried pace. Phrase Finder says it appeared in print in Scotland in 1829. I enjoyed the reference to Groucho Marx saying to a female character in Duck Soup, I could dance with you till the cows come home. Better still, I’ll dance with the cows and you come home.”