For a fiction film, sound recorded poorly on the set can be remedied by rerecording the dialogue later in a studio (called ADR—automatic dialogue replacement). Even on an otherwise well-recorded movie, ADR may be necessary for scenes shot in noisy locations or where mics are impractical. ADR, of course, takes money and time.
On a documentary, ADR is not done (even if it could be, most would argue it shouldn’t be). Many a great documentary scene has been abandoned on the cutting room floor because of unintelligible sound