How does grammar help writing? And who should teach it?

The way we teach writing is clearly failing. It's not all down to English teachers. We need to teach school students to write for each subject.