Party till the cows come home is an expression about staying out all night and partying the whole time. My informant said that the saying specifically means staying out until the sun comes up, but can be used without staying out that long. One might say it to joke around with friends when they won’t actually being out that long. He believes that the expression started by farmers who had to milk cows in the morning, but had no responsibilities until then. He believed that the expression then caught on and spread to others even though the expression would not make sense for them.
The reason for this piece of folklore existing seems to be sound, as otherwise it would seem to be random. While my informant has never worked on a farm or knows anyone who did he still said the expression was fairly common showing that even if that is how the expression began that is not how it is spread now.