They're dipped in an alkaline bath before baking.
The secret to a pretzel's deep brown, glossy crust and distinctive flavor is a quick dip in an alkaline solution before baking. Traditional German bakers use a weak solution of food-grade lye, sodium hydroxide. Home bakers often use a baking soda bath instead, which works similarly but less strongly.
The alkaline bath changes the surface of the dough. It breaks down some proteins and starches, which speeds up the Maillard reaction in the oven, giving the crust that rich mahogany color and slightly tangy, savory pretzel taste. It also sets the outside into a thin, shiny, chewy skin.
Lye sounds alarming, but it reacts during baking and none remains in the finished pretzel. Bakers wear gloves when handling it.
Bagels are often boiled in a baking soda or malt bath for a similar reason. Pretzels have deep roots in Pennsylvania, where German immigrants brought them, and Julius Sturgis opened what's considered America's first commercial pretzel bakery in Lititz in 1861.