The strategic answer to the main question is: Field Position
Please see this article: https://www.football.com/en-us/charting-the-importance-of-field-position/
Basically, as you get farther away from the goal posts, the chances of successfully making the kick get lower and lower. As you can see in the linked article, as you get better and better starting field position, the chances of you scoring get higher and higher. Also a key factor here is that on a field goal, if you miss the field goal and the other team does not decide to return it, the other team gets the ball (their starting field position) on your previous line of scrimmage.
So putting all of those things together, it is a much smarter strategic move to give up on the chance for 3 points, given the possible negatives, but instead use a punt to "pin your opponent deep" and give them very bad starting field position (optimally at their own 10 yard line or less.) Their odds of scoring are lower, and...