Anyone who is a writer knows that being a writer and being an editor are two completely different things. A writer is someone that can take a thought and turn into a magical prose that drives people to read on. They can turn words into an emotional connection.
An editor is someone that knows grammar like the back of their hand and can take existing copy and perfect it. They are often mutually exclusive. I admit that my grammar skills are atrocious even after more than a decade of constant writing. Luckily, I married an editor. Together, we make the perfect team.
The question is what do agents and publishers expect when they finally see that finished manuscript? Do they want perfection? Yes and no. When you send in a final manuscript for them to see, it has to be polished to the best of your ability. That means going over every word over and over again until you think it's the best you can do. You might even want to pay an editor to go over it for grammar.
A publisher and agent would love to see a finished product that doesn't need any changes, but those are rare. A book that doesn't need a good once over by a professional editor is rare. Your book should be grammatically correct. Nothing makes an agent or publisher mad faster than sloppy copy. Plot and structure edits are common, but grammar edits are a death knell for a writer.