Do authors going the traditional publishing route need to have their manuscripts professionally edited before submitting them to a publisher? The answer is a qualified "maybe."
I see a lot of unedited material come across my desk. You'd be surprised at the number of manuscripts I receive with misspelled words and basic grammar mistakes. (Basic = incomplete sentences, mixed verb tense, punctuation mistakes, etc.) Now, I understand that there's no such thing as a perfect manuscript. I don't even blink at a few errors here and there. I'm talking about multiple mistakes PER PAGE!
Then there are the content errors. I get manuscripts where the main character's name is spelled several different ways. Or their hair color changes part way through. Or a secondary plot line is started, then dropped, never to be picked up again or resolved.
These are basics. These mistakes will get you rejected. A publisher won't do that much editing on a book, even if it is a wonderful story. Also, these types of mistakes are interpreted as a sign of unprofessionalism, ignorance or laziness. If an author isn't serious enough to do the bare minimum required to put their best work forward (ie: run the spell checker), then I'm not going to spend serious money publishing it.
To avoid these mistakes, you need readers. Remember, no one can edit their own work. At a minimum, I'd say have several (6 to 10) readers go through it looking for errors before you submit. These readers need to be competant spellers and grammarians, and have a sense of what makes a good story. Fellow writers, particularly published writers, are usually good at this. IF, after you've revised and corrected based on your readers' comments, you feel you've got a pretty clean manuscript, then go ahead and submit.
If your manuscript keeps coming back, particularly if an editor/publisher in any way indicates that your book needs editing, then you should consider hiring a professional.