Grammar is the technical aspect of a language, any language. It can be mastered by memorizing and practicing all the available rules.
Idiom (the peculiar character or genius of a language; a style of speaking peculiar to a people) is something one can only learn through experience, even though the process can be greatly facilitated through memorization of well-written texts and traditional (i.e. metered) poetry. Keeping an open mind can help a lot.
Music is the one analogy that springs immediately to mind. Computers are far better equipped than humans to master the technical aspect of music. Melody, harmony, orchestration, counterpoint, etc: it ain't rocket science. That said, no computer can distinguish between a good opus and a mediocre one; no machine can assert, based on its analysis of the two scores, that which a human connoisseur will tell you instantly: that brilliant as it may be, Giacomo Puccini's Turandot is less brilliant than Tosca, written by the same composer.
Certainly no computer is capable of writing its own masterpiece comparable with Wagner's Siegfried, Verdi's Rigoletto, or Tchaikovsky's Pique Dame. The technique may be there, but something will always be just a little off: machines, they just don't get it.
Children master their native idiom before they even find out that there is such a thing as grammar. A child's unfiltered mind and pure soul is naturally attuned to the music of their mother's tongue (or, in some cases, their nanny's and governess's tongue). Grownups trying to learn a new language do not have that luxury: the language, or languages, they already know weigh heavy on them. They need grammar to help them "get the hang of it."
Each time you encounter a situation where something is grammatically correct yet sounds awkward, lame, or downright moronic, do not despair, and do not ask why there's no rule that might help you understand it. Learning a new language is not an exclusively intellectual pursuit: there's a spiritual (ineffable ... divine, if you will) aspect to it; language is akin to such intriguing concepts as faith, hope, and love: we all know what those are, we understand their function and purpose, but we can't define them, nor can we satisfactorily explain, even to ourselves, how they work.
An idiomatic turn of phrase works because it fits, and not because it's grammatically correct (or not).
You'll recall Wordsworth:
The sea that bares her bosom to the moon;
The winds that will be howling at all hours,
And are up-gathered now like sleeping flowers;
For this, for everything, we are out of tune;
Why is the sea suddenly female, and the moon male? Who knows. But it does somehow make perfect sense in this context, does it not. That said, should your knowledge of grammar be sufficient at this point, and should the word scansion mean anything to you, you'll immediately realize that "we are" should be spelled "we're" to make the line scan.