On 3rd down (out of field goal range) if your choices are dump it down for a short gain and no first, or hold it and risk getting sacked but have the opportunity at a big play the penalty for the sack is not that high. Punting from your 40 vs your 30 doesn't change much, NFL punters can all punt over 65 yards.
NFL punters don't average anywhere close to 65 yards. Even if they did, coverage usually can't cover that much distance that quickly. Long punts usually equal long returns. So 10 yd will absolutely make a difference. You just described a situation in which it would be a stupid sack to take. You'd be sacrificing field position. Not to mention the injury risk and wear and tear build up on your quarterback. You're using a video game logic.
Touchbacks? That's the only reason?. They punt from their own 20 they're worried about it going out of the back of the end zone? Come on man. You don't have to play dumb like this.
All punts are not from the 20, that's why average punt distance is not a good metric some punts are from the 30 some the 40, and even some from the 50.