A dozen is a counting term used to describe 12 of something. But when you have a baker’s dozen of bread, you have 13 pieces of baking, not 12. This may seem like a charitable gift from the baker, but the historical origin is somewhat different.
In the Middle Ages (particulary around the 13th century), baking was not an exact science and loaves of breads were made with varying sizes and weights. This made it easy for bakers to short the customer by giving them smaller loaves than what the customer needed.
To stop this, many countries implemented laws that prevented bakers from shorting the customer, usually by setting a minimum weight for a dozen loaves of bread. However, it is entirely possible for the baker to lose a few loaves of breads to accidental dropping, burning or thieves stealing them. Because the breads may come out smaller, it could not be guaranteed that a dozen loaves would be heavy enough to meet the guidelines – no matter how honest the baker was. To offset this, bakers began adding an extra loaf to ensure that they would not disobey the law (and pay a hefty fine or be seriously punished).
Another theory with less historical evidence is based on the shape of baking trays. Most baking trays are made in a 3:2 ratio and the most efficient way to place loaves of breads on these trays is a 4:5:4 hexagonal arrangement. This arrangement has the advantage of avoiding the corners, where the temperature will heat up then cool down faster, making the results less perfect. Therefore, bakers may have sold a batch of 13 loaves together instead of selling 12 and leaving one out.