UPDATED FEBRUARY 2023
My view on grammar (and its cousins spelling, punctuation and usage -- a family I call SPUG) is that it's literally the last thing to worry about when you're writing.
Yeah, that doesn't win me many friends among the grammarians and English teachers in the group, but it's true. Hear me out:
When we are too focused on these very important technical requirements early in the process it gets in the way of other things we need to be thinking about, like our ideas, how to organize them and the voice we use to say them.
I don't know if it's true, but it feels like I'm using a totally different part of my brain to work on these bigger things.
When we're planning and drafting, we need to evaluate concepts, figure out logic and choose the right words to convey our meaning. This is critical thinking. Of course we're using grammar and the other stuff, but it's happening more in the background. If we bring the grammar-checking function too far forward, it can easily get in the way of getting the ideas, words and logic right. So those need to come first.
Worrying about SPUG too early creates additional and unnecessary work, too. We've all experienced the pain of having to delete an entire paragraph we painstakingly corrected because it turns out it's not really necessary, or we're over word count or whatever. Getting the evaluative writing and revising work done first lowers the likelihood of investing time in sections that will end up on the cutting room floor.
Again, this isn't to say "don't fix errors when you find them". Every time you go through your text you'll probably find SPUG issues you can quickly fix. Just don't get derailed about whether you need a comma while you're drafting. Keep your mind in the zone.
Then, just before you're ready to publish, send, etc., switch gears and focus on the tiny, technical and hugely important grammar, spelling, punctuation and usage.