Several hundred years ago, bakers used to have extremely strict laws because it was so easy for them to cheat buyers by shorting them on bread. These laws even go back to ancient Egypt where someone could have their ear cut off and nailed to the door if they were caught cheating. Bread was especially important because it was often the only thing available for poorer people to eat, and in times of famine, bakers were likely to cheat.
To avoid the harsh punishment of being caught as a cheat, bakers began to add an extra piece of bread, which ensured that there was more than what was purchased and they were being honest. So when people came in and asked for a dozen loaves, they would just include 13, which eventually came to be known as a baker’s dozen!