The joke is a play on words.  Dairy cows on a farm are milked by farmers squeezing their udders into a bucket.  The phrase 'milked it for all it was worth' can typically be used to mean that someone who was injured or has some valid court charge against someone else abusing the power to get as much profit out of the court case as possible.
Did you hear about the farmer who got attacked by a cow ? He milked it for all it was worth .