To milk something means to thoroughly use something to one's advantage. Cows produce milk. The verb milk is the action taken to retrieve milk from a cow. The joke is centered around the word milk and its different meanings. 
The farmer decided to get a cow , and milk the idea for all it was worth .