To say “stand up straight” is a bit of a misnomer; the body is made up of a series of curvatures.
When you look from the side at someone standing up straight, you’ll see that their body actually follows a curve which begins at their heels and ends at the top of their head. Think of a hunting bow: when a bow is strung, the bowstring holds both ends of the bow together, allowing the structure to store a magnificent amount of potential energy, to be released when an arrow is loosed. The extensor muscles of the body (hamstrings, glutes, and back muscles) perform largely the same function as the bowstring:
The quintessential proud or dominant posture is achieved by tensing the extensor muscles to align the majority of the bones in the body to create a series of arches, or bows. By maintaining tension in this way, the body creates a firm (yet dynamic) structure. This isn’t a spurious analysis: throughout the history of architecture, arches have been the quintessential support structure. For these same reasons, suspension bridges are built in high-wind and earthquake-prone areas: because using tense cables to support the structure not only maintains the bridge’s shape very well, but does so despite the power that wind or seismic events can exert on it. By contrast, a bridge that is completely rigid through and through would be far less resilient.
Because the body is a moving system (as opposed to a rigid system), it creates these arches in order to more easily engage with the forces that routinely interact with the body, such as the force of gravity and the kinetic energy generated during exercise.