Importance: the idea that what students are writing is actually important. Not just for their grade, or for practice, or for fluency, but for their community, their world. It's relevance, it's contextualization. This importance is what results in real motivation.
The real question is how do you develop units/investigations/activities that are actually important? That people outside of your classroom actually care about?
Not kit-based, cookie-cutter lab science ... real science. Science based in their local ecology, science that is rich in data-collection, science that describes patterns and changes. It's the citizen science project that engages students in collecting sand crab data, it's the water quality project in the local creek, it's the schoolyard habitat restoration project, the conservation unit that results in cafeteria waste audits or geotagging litter and measuring your collective impact, it's the engineering project where students build models of the proposed new pier.
To motivate students to write, it's old school ABC - Activity Before Content. You start with a real-world, important long-term investigation. And you write about it. You write your predictions, you write your background knowledge, you write about your observations, your data, your next questions, the connections you make, the revisions you do, even the reference material you read. Not in a science-fairy way, in a real, reflective and inquisitive way. It lends itself to writing mini-lessons, writer's workshops, and real writing instruction. It demands sharing your writing with a larger audience - communicating your results, your message.
And that motivates.