It’s not that a punt is ‘allowed’ on free kick after a safety, rather, it is that a punt is ‘prohibited’ on a kickoff. That is because the ball flies so high, punting the ball on a kickoff allows Team A to get coverage players much farther downfield than with a place kick or drop kick. It becomes a bit unfair to Team B to do anything productive with the ball, and nearly guarantees a recovery by Team A if Team B doesn’t make a good clean catch.
As for why such a kick can’t be made from more than one step behind A’s restraining line, Ralph gave an answer that’s as rational as any for NFHS rules. (NCAA allows a punt or drop kick to be made from anywhere behind A’s restraining line on a kick after a safety.)