According to the Phrase Finder, this was originally a nautical term when berth was used to describe where a ship would be moored. Sailors were warned to keep a wide bearing to maintain sea room around a moored ship. Captain John Smith used a version of the term in 1626. “Watch bee vigilant to keepe your berth to the windward.” In 1829 Sir Walter Scott wrote “Giving the apparent phantom what seamen call a wide berth,” which led to the current meaning of maintaining a goodly distance.