Because common sense says that the punishment should vaguely fit the crime. In other areas of the pitch the referee uses their judgement when giving out yellow cards. They take into account things like how bad the foul was, how intentional it was, what part of the pitch it happened on, how early in the game it is, how nasty it was. When calling fouls they consider whether there was enough contact, did the player touch the ball, how much of a touch did they get vs how much of the player, did their team still have the ball afterwards ie. play advantage.
Imagine if there were random spots on the pitch where a foul inside them would be given as a penalty. It would make no sense. It would make no sense because a penalty is basically a goal so the requirements for it should be high.
There is no reason to think that referees shouldn't use the same thought process when deciding on penalties in the box vs using something like an indirect free kick or whether to simply ignore it completely because the attacker had 0 control of the ball.
If you ask the question "why did the attacker go for the ball in the box when they had no chance of getting it under control" and the answer was "to try and win a penalty by getting a touch a fraction of a second before the defender" then it probably shouldn't be a penalty.