The earliest variant of the phrase I could verify in print was 'cheaper in the dozen', from an article in the [*Hartford Courant* (Hartford, Connecticut) of 24 May 1790][1] (paywalled, emphasis mine): 

> In New-York the price [of Webster's Spelling-books] has commonly been thirteen shillings New-York currency a dozen, which is three-pence lawful money *cheaper in the dozen*....

The exact phrase 'cheaper by the dozen' turns up a dozen years later, in the [*Hartford Courant* (Hartford, Connecticut) of 12 Jul 1802][2] (paywalled, bold emphasis mine): 

> N. B. Said *Chadwick* will sell Morocco [leather shoes] **<em>cheaper by the dozen</em>** than can be bought at any store in this state.

Considering the context of the early uses, and the semantics of the phrase itself, the origin of the phrase is likely to have been marketing jargon.

With due respect to the fanciful folk etymology you encountered, which in fact deserves only scorn and disrespect, I observe that the phrase was more recently popularized by the [1948 book *Cheaper by the Dozen* (Frank B Gilbreth and Ernestine Gilbreth Carey)][3], a central theme of which was the putative efficiencies of having a dozen children. Thus, it might be proposed that the title of the book derived from the obviously fictitious practice involving prisoners-of-war. 

However, even supposing the authors of the book confessed that the title was sponsored by a scurrilous story, the story itself betrays ignorance or disregard of genetic principles by ascribing "severe birth defects" to a single generation of inbreeding. 


  [1]: https://www.newspapers.com/search/#query=%22cheaper+by+the+dozen%22
  [2]: https://www.newspapers.com/image/233630606/?terms=%22cheaper%2Bby%2Bthe%2Bdozen%22
  [3]: https://www.worldcat.org/title/cheaper-by-the-dozen/oclc/1001483675/editions?sd=desc&referer=br&se=yr&qt=facet_yr%3A&editionsView=true&fq=yr%3A1948