Grammar is the foundation of your writing. Just as a castle, a church, or a house needs a solid foundation to support the rest of the structure, your writing needs the support and foundation of good grammar. Good grammar holds up your sentences. Readers can more easily understand what you want to say if they are not distracted by grammatical errors.
For instance, do you know when you should write lay and when to write lie? Errors like writing "your" which infers ownership, "is that your new car?" when you want to say "you're" meaning "you are" as "you're the new class president," not only confuse the reader but send up red flags.
If you have a grammar question there are plenty of books out there ready to help you. One of the best is Strunk and White's classic THE ELEMENTS OF STYLE. If you enjoy a Grammar book with some humor, see if you can snag a copy of William Safire's book, https://www.amazon.com/How-Not-Write-Essential-Misrules/dp/039332723X?crid=32OS2QICBLD9B&keywords=How+not+to+write+The+essential+Misrules+of+Grammar&qid=1656171506&sprefix=how+not+to+write+the+essential+misrules+of+grammar%2Caps%2C57&sr=8-1&linkCode=ll1&tag=loisthompsonb-20&linkId=a60b8393e68e07406fd5caf31ce52bc8&language=en_US&ref_=as_li_ss_tl
NOT TO WRITE, THE ESSENTIAL MISRULES OF GRAMMAR. You can check up on your writing with a smile on your face.
The Secret Way to Learn Good Grammar
There is a "secret" way to learn good grammar, though, without studying a textbook. And that is by reading stories--- reading, and reading some more.
Think of your favorite books, then read those stories again. What are your friends reading? Pick up a new library book and read it. Then go the extra mile and tell someone about that story. What did you like best? What didn't you like?
But while you are reading, keep a part of your mind open. Pay attention to the language and how the sentences are put together.
Have you ever read a sentence that takes your breath away? Does the adventure story you just finished reading have the "perfect" ending?
How long has it been since you read a book out loud to a little kid or to yourself? Do you read your own writing out loud? That is a good way to catch any grammar mistakes. I belong to a writing group. When we meet, we often have the author of a story read it aloud to the rest of us. It is rare that someone reads a story and doesn't find at least one or two errors.
And beware of auto-correct! I received a text message from a friend last week and auto-correct had made so many "corrections" I couldn't figure out what she was trying to say.
The more you read, the more your writing will improve. Couple that with a bit of grammar study and lots of practice writing. Remember, grammar is the foundation, the base of your castle. The elements of grammar fit together like well-cut stones to build your story. They create the battlements, the jousting field, the courtyard, and the banquet hall.