Carl Gottlieb was hired for what was meant to be a one-week dialogue polish and ended up the primary screenwriter, rewriting nearly the whole script across the nine weeks of principal photography. Wikipedia’s account of the production notes that each scene’s pages were typically finished the night before shooting, after Gottlieb had dinner with Spielberg and members of the cast and crew to decide what would go in — and that many pieces of dialogue originated in the actors’ improvisations at those dinners, with a few created on set just before filming.
That is the working method that makes an unscripted line plausible rather than legendary — but it is background, not the explanation for this one. Gottlieb’s own account points somewhere else: not a dinner-table improvisation, but a running gag the unit made at the producers’ expense about the boats they had been given, which Scheider kept feeding into takes until one landed. Either way, the screen credit and the authorship of any single sentence are different questions here: Benchley and Gottlieb hold the credit, John Milius and others contributed uncredited polishes, and the film’s most famous line came from neither the script nor the rewrites.