You only need a couple of mm.
However, if something goes wrong, a little extra clearance can be nice.
I blew off about 3" of the bead about halfway through a 150 mile ride. There was probably a bike shop 10 miles behind me, or 20 miles ahead. Very narrow chainstays. I struggled to boot the tire and not have it rub.
I've also broken spokes from time to time. So, either riding home with a wobbly wheel, adjusting the wheel so it is marginally true with one less spoke, or replacing the spoke in the field, and truing it the best one can on the side of the road.
And, of course people may change tire sizes from time to time. So, 23mm tires are falling by the wayside for 25mm, or even larger.