Becuase when someone writes, they should be thinking about what they are trying to say and how they are trying to say it. It's hard to imagine someone without basic spelling skills having the spelling automaticity required to write well.
Or, the cognitive load of trying to spell each word can prevent someone from thinking about what they are trying to write. But if their spelling is automatic, they can think about their writing.
Schools and students develop spelling and writing automaticity largely through practice. Here's some great resources for practicing for each grade level. For second grade spelling, third grade spelling, fourth grade spelling, and fifth grade spelling.
In second grade, and I quote: Second grade spelling word lists include Dolch and Fry sight word lists and word structure lists (compound words). Second grade students can build sight word fluency and phonics mastery through the use of VocabularySpellingCity’s interactive online games. Second grade games feature both audio and visual elements, an effective learning tool for all maturing readers and writers, specifically English Language Learners (ELLs).
And quoting from the 5th grade materials: