The horse raced past the barn fell.
Is it a grammatical sentence? Actually, yes. But, sometime while you were reading the sentence, you had to backtrack and reinterpret a word seen in the past in order to make the sense of the whole sentence fit. Explicitly, when you first read this sentence, you may have thought that raced was the main verb of this sentence, but upon encountering fell, that interpretation was not plausible anymore, therefore reinterpreting raced as the past participle modifying the head noun (horse) and giving fell the correct interpretation as the main verb of this sentence.
Now why is this called a garden path sentence? Because of the metaphorical image that garden paths provide, that some paths lead you to dead-ends and you have to backtrack and find your way out.
Of course, there are ways to disambiguate these sentences, and in the above example, one way can be by just not reducing the relative clause, as in the following.
The horse that was raced past the barn fell.
Most of the time, lexical ambiguity plays a role in whether a sentence is a garden path sentence or not. World knowledge also plays a role, such as seen in the next sentence.
The bomb buried in the sand exploded.
This sentence has the same structure as the first one, but world knowledge tells us that bombs do not bury things due to the fact that they are inanimate entities, which decreases the likelihood of interpreting buried as the main verb of this sentence.
Now what do garden path sentences tell us? Well, they prove one important point in psycholinguistics, that is, human sentence processing is incremental. Humans process words and sentences the moment they see them, and repair them later if needed. It is not the case that humans wait for the period at the end of the sentence and then start processing, no, processing as it occurs in the brain is an automatic event, and the fact that we backtrack and reinterpret things proves that we process things one-by-one until we hit an obstacle, to which we give a different interpretation to a previously processed item in order to make the whole sentence fit.
Some more garden path sentences:
The old man the boat.
Fat people eat accumulates.
We painted the wall with cracks.
I convinced her children are noisy.