Perhaps the best answer to your question would be to point out that the positive affects (the range from interest through excitement, and the range from contentment through joy) feel so good that the organism would be likely to get stuck in them. Analogous to the way some animals (like deer) can be "jacklighted" or truly paralyzed when a bright light is shone in their eyes, or a moth torched by its fascination with the light of a flame, we humans are wired to maximize positive affect. Shame affect has evolved as an amplified analogue of any interruption in the ongoing stimulus that has triggered positive affect. It is an amplification of the interference because the way we turn aside, blush, are unable to think clearly, and so forth, take our attention far more powerfully than does the perhaps momentary and otherwise minor impediment to the preexisting positive affect. And it is an analogue because it shares the characteristics of the interference (indeed, the affect becomes a major interference with positive affect) but is not the same as the original impediment.
Complex language!
Yet without such language it is easy to slip into the common idea that shame itself is the mature presentation of the emotion as we come to know it as adults. More likely, we start life with the mechanism for analogic amplification of impediment to positive affect, and with its protection we go through our formative years learning about all the situations in which it can afflict us. Of all the affects, I think that shame achieved the majority of its power as the human brain evolved to allow the storage, retrieval, and association of thoughts and experiences that make our life form so unique. The more we can remember about our personal identity, the more we can be afflicted by shame affect as it forces us to think deeply.
So in answer to your question, I believe that shame affect evolved late in our path toward humanity, and that it became increasingly important as our cerebral equipment allowed new and increasingly human function. What do you think?