Part of what a sentence means depends upon its separate words, and part depends on how those words are arranged.
Round squares steal honestly. Honestly steal squares round.
What makes these seem so different in character, when both use the very same words? I'll argue that this is because your language-agency, immediately upon hearing the first word-string, knows exactly what to do with it because it fits a well-established sentence-frame. The second string fits no familiar form at all. But how do we fit those sentence-frames? We'll come to that presently, but for the moment, let's simply assume that our young listener has somehow come to classify words into various types, like nouns, adjectives, verbs, and adverbs. (We'll ignore the fact that children go through other stages before they use words as adults do.) Then our first string of words has this form:
Adjective Noun Verb Adverb Now we'll suppose our listener has learned a specific recognition- frame that is activated on hearing this string of particular types of words. This frame then executes a special process script that makes the following assignments to the terminals of a Trans-frame. The neme for steal is assigned to the Trans-frame's Action terminal, while the neme for squares is attached to the Actor terminal. The frame then activates scripts that modify the action steal by applying to it the neme for honestly and modify the object squares by applying to it the neme for round. Up to this point, everything works smoothly: the language-agency has found a use for every word. We have special names for the strings of words that we process with such fluency: we call them phrases or sentences.
A word-string seems grammatical if all its words fit quickly and easily into frames that connect suitably to one another.
However, at this point some serious conflicts start to appear within some other agencies because of certain incompatibilities. The frame for steal requires its Actor to be animate. A square can't steal, because it's not alive! Besides, the frame for steal expects an act that's reprehensible, and that clashes with the modifier for honestly. If that weren't bad enough, our agency for describing shape can't tolerate the polynemes for round and square when both are activated at the same time. It doesn't matter that our sentence is grammatical: so much turmoil is set up that most of its meaning cancels out and we regard it as nonsense. But it is important to recognize that the distinction between sense and nonsense is only partly a matter of grammar, for consider what happens when you hear these three words:
thief -- -- careless -- -- prison --
Although these do not establish any single well-formed grammar- frame, they activate some word-sense nemes that skip past all our grammar-forms to fit a familiar story-frame, a moral tale about a thief who's caught and reaps a just reward. Ungrammatical expressions can frequently be meaningful when they lead to clear and stable mental states. Grammar is the servant of language, not the master.