Sticking to good editors only: editors, from their background and experience, see the book as a whole, in relation to not only that writer's other books, but all other books. They must grasp--for every book, every writer--what that book tried to be, and where it doesn't achieve the writer's goal.
This is easiest if the writer and editor started with the same conception of the book and can communicate in the course of the writing about the direction the book is taking. If the writer can outline well, if the writer can do some pre-writing or early-writing analysis, and the editor has time to listen and perhaps make suggestions, the writer-editor collaboration usually goes smoothly.
That's not always possible. Writers like me, intuitive and discovery writers, can't always (often!) talk analytically about a book before it's at least half done. This leaves the editor uncertain what the writer was trying for, until the manuscript comes in...and then the editor must quickly get on board, figure out the writer's purpose and analyze the manuscript to see if the book is doing what the writer (apparently) wanted. I understand that this can be harder for editors, but working the other way is impossible for some writers, and I'm one of them.
So...let's say my manuscript comes in, and I'm happy with it (actually, I'm sick and tired of it and never want to see it again for at least a week...) Like most professional writers, I'm reasonably skilled at the craft: my sentences are sentences, my paragraphs are paragraphs, my spelling and punctuation are (barring a typo here and there) correct, and so on. No editor should have to battle his or her way through thickets of illiteracy; that's not what they're there for. But no writer (OK, almost no writer) is perfect. I make mistakes, more important than a typo that leaves a teh where the should be. I fail to see (and my friends the first-readers fail to see) where the story goes soft--where it lacks muscle tone--or where it feels thin. There's always more in my head than goes on the page, and my selection process (how much sensory detail, how much background, etc.) can be--is, at least once in every book--flawed.
So the editor, the good editor, spots those places. For instance (all examples are made up for this post), the editor might say "In chapter four, when Brent storms out of the room after Julie tells him his brother was arrested, it's not clear whether he's mad at Julie for telling him, or his brother for being arrested, or both." Or "You're building suspense all the way through chapter seven, and the big confrontation is in chapter nine, but chapter eight is just...slack." In other words, the editor keeps track of pace, tension, motivation...spots places where these aren't clear or otherwise create a problem for the reader.
The editor does this not only within the manuscript--that story--but with the background of many, many such stories, aware of how the book paces compared to others of its kind, how the plot is structured compared to others of its kind, whether the motivations of characters will make sense with the most likely readers for its kind of book. Perhaps the writer has become fascinated with something that is actually background (I do this...) and needs to be reminded (as I was once) that "not everyone wants to read that much about fly-fishing." Perhaps a whole lovely, lyrical, beautifully crafted chapter in which things appear to be happening...really has nothing to do with the plot (yup, that one happened to me, too.) Perhaps the writer has spent too much space on a minor character--not in the writer's mind, where the entire cast of characters must all be real people with real lives, but in the book, where that character's job is to step onto the stage, announce that Mr. Jones is here for his nine o'clock, and then disappear.
So back from the editor comes the always-dreaded editorial request for changes. Editors differ in how they do this (phone, email, hardcopy) but it boils down to "here's what's wrong with your book" and in some cases "here's what you have to do." The good editor (the only one I'm going to talk about here) makes it clear why this section didn't work: it was slow, it was confusing, the motivation wasn't clear, there's a lump of exposition in the middle of what should be an exciting scene, etc. The smart writer waits 24 hours (because, inevitably, there's a moment or two of howling "NO! It was PERFECT! I don't WANT to!" and then asks (politely) about any editorial comment that isn't clear. Quite often I think I've made something clear (I know it from the inside, as well as the outside) and I need to know very precisely why it wasn't clear to the editor. I may say "This is the effect I was trying for...can you tell me what cues you would have needed, or what cue in the manuscript made that reading impossible?" Good editors always can. Less good editors--OK, I will mention them just this little bit--sometimes have formed a firm idea about exactly how the writer should have said what the editor wanted said. I find this difficult, because if the editor has failed to catch what I was actually trying to do, the fix that's demanded may be entirely wrong for that purpose.
But with good editors...it's kind of like the way my choir director deals with our choir. We sing the music; it usually sounds good the first time. He asks two altos to check their vowel sounds, asks a soprano to sing less brightly, asks a tenor to sing out, reminds the basses that they must enter precisely on the eighth...and we do it again. It's better. He tweaks one voice after another, checking the balance of the entire choir (the whole book, in other words) and better than any individual singer could do, he clarifies our sound until, quite suddenly, the music is perfectly there, unencumbered, untarnished or smudged by the frailties of any individual. The editor nudges the writer here, and there, and tweaks this and murmurs about that...and suddenly the book is more itself, more what it was capable of being, than it was before.
Choirs need directors. Writers need editors. The better the choir, the better the director must be, to see how to perfect and grow that choir. The better the writer, the better the editor must be, to see how to perfect and grow that writer.