The riddle
Why Did the Cow Cross the Road?
Udder against other
Wiktionary gives udder as /ˈʌdɚ/ and other as /ˈʌðɚ/ in American English. The vowel and the ending are the same. Only the middle consonant changes, a d in udder and the soft th of "this" and "that" in other. That makes the pun a near match and not a perfect one. In accents that turn th into d, which Wiktionary calls th-stopping, the two words are listed as homophones. Everyone else forgives one small sound, and the groan that follows is part of the fun.
Two unrelated old words
Both words reach back to Old English, according to Wiktionary: udder from ūder and other from ōþer, and the entries show no connection between them. Wiktionary lists cousins of udder in other languages, such as German Euter, Dutch uier and Latin ūber. The riddle works by accident of sound, with two words that drifted to nearly the same place. An udder is the milk-producing organ of animals such as cows, goats and sheep, and that single fact is all the joke asks of it.
Borrowing the chicken's question
The frame is the famous one about a chicken, and the cow gets it by swapping the animal. Barry Popik's joke-history site keeps an entry for this exact question and answer. Other cow versions bend a different word, such as moo-ve for move. A new animal only works if it brings a word of its own to bend, and the cow has one. For the source of the frame, see the chicken question.