Those are two different questions!
Yes, stories get rejected because the stories are not appealing enough.
No, if the writing is bad, the story premise probably doesn't matter, the writing will be rejected anyway.
Publishers & editors & agents are all basically the same when it comes to judging a book, Let's call them gatekeepers. Gatekeepers are primarily interested in making money by selling books to the public. Cool new ideas? Sure, those can sell.
But gatekeepers are not really interested in teaching, or babysitting, or hand-holding. They have plenty of authors that are good at both writing and inventing stories. Imagination is not in short supply out there!
Many of these gatekeepers look at only the first five pages of a book, no more, before they decide whether to read it. Some will not read past the first half page. That should tell you the answer to your second question: If the writing is poorly done, they reject immediately. First books generally return very little money to either publisher or agent, and are only worth their time and energy if there is very little work to do on the writing part.
If the writing is done well, then the commercial potential of the book becomes an issue: If readers will be disappointed by a poorly crafted story, then again, the book is not going to sell well.
The primary driver of sales is endorsements to friends (or the public) by "early adopters" that took a risk and bought the book. Early Adopters are the small percentage of readers (maybe 3%) that make a habit of reading new authors, taking a chance on buying a new book and being the first to find a new gem, even if they are often disappointed. They tend to be able to afford this habit (in time and money) and to enjoy being in on the ground floor, being the first to discover a great new author, etc. It is a personality thing. Most importantly, they are trend leaders, others that are more risk-averse let the Early Adopters risk and lose, and then jump in when the Early Adopters say it is worth doing. If you don't break through the Early Adopters, you don't sell books.
Agents tend to be an extreme version of Early Adopters, they just figured out how to make money at being the first readers, and recommending their great finds not just to friends, but publishers (with editors).
Many agents request just the first five pages of your novel to judge it. A query letter with that may tell the basic story, but if the writing is not good, out it goes. It just isn't worth their time, and their stack of submissions is typically endless. Gatekeepers tend to be fast readers, finishing quicker than a page a minute. You get about ten minutes of their time to convince them to invest more time than that. Then you are done, or they do the work of requesting your manuscript. They may STILL not represent you if that needs too much work, or if it turns out your story is not satisfying or has big plot holes.
You have to do both. Write well. Write a good story. Even that is no guarantee of sales. For some reason or another, these "first readers" have to feel like they really want to tell their friends about your book and share the experience of it. I'd call that "emotional impact", their takeaway from the first read cannot be just "nothing wrong with it," it must be enthusiasm to share it (or sell it).