William Rapaport of the University of Buffalo (naturally) devised the construction in 1972. How can it possibly be correct? First, let’s look at the sentence with his original capitalization:
Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.
Esther Inglis-Arkell of io9 unpacks its meaning:
“So, buffalo who live in Buffalo (e.g., at the Buffalo Zoo, which does, indeed, have buffalo), and who are buffaloed (in a way unique to Buffalo) by other buffalo from Buffalo, themselves buffalo (in the way unique to Buffalo) still other buffalo from Buffalo.”
The sentence relies on a few tricks. The first is that “buffalo” is a verb as well as a noun and the name of a place. To buffalo someone is to confuse or fluster a person. There’s also a missing “that.” Under normal circumstances, we can sometimes drop a “that” from a sentence, as long as the nouns still make the meaning clear. For example, “things I knock down don’t get back up,” and “things that I knock down don’t get back up,” are equally clear. All-buffalo sentences muddle it up a bit.
Rapaport wrote it for a philosophy class experiment when he was in graduate school.