If left to their own devices, cows in pasture will regularly show up at the barn for milking twice a day, once in the morning and once in the evening.
The expression “’til the cows come home” first appeared in the sixteenth century when most people were familiar with the cycles of farm life.
It was often used when a party went on long into the night.
The party would have to end in the morning when the cows came home and needed milking.
So the expression “until the cows come home” means a very long time.