When did humans start wearing clothing (of any type) and why did it become important enough to be necessary to wear in public?
This is a very difficult one to answer because it predates recorded history.
Subsequent generations have tired to explain it through the rules of religion (examples: Adam & Eve and the fig-leaf in Christianity, the Sekhiya Rules in Buddhism, Vedic period rules of modesty in Hinduism, various Hadiths in Islam, Tzniut in Judaism).
But the fact remains that genital modesty, as an etiquette (if it can be defined as such) appears to have pre-dated many or all of these religions.
In historic terms,
"practicality" is often the impetus for "change".
"Change" then finds its way into "philosophy" (as it becomes debated), and
"philosophy" has often found its way into "religion".
If we break down this 3-step approach to historical enshrinement of morality, we can ask ourselves what the "practical" origins may have been. This may give clues to the historic origins of clothed genitalia (and this is totally NSFW btw).
Public nudity may have become unacceptable when people began to form settlements (transitioning from hunters/gatherers to being agriculture/animal husbandry-sustained communities).
With the advent of settlements/communities came new realities which may have required "practical" solutions. With settlements came increased leisure time. Settlements also provided security with which to grow of a community's population.
With lots more time and many more people comes quite a bit more sex (jumping from hut-to-hut and house-to-house).
With much more sex comes many more horrific STDs. A good number of STDs can be visibly apparent for men, not to mention some nasty-vile ones which are visibly apparent for women...
It's perhaps at that moment (when we ceased being hunters/gatherers) that these new societies realized that nobody's got time to showcase that! (Let alone who would want to look at that!).
And hence, this may be the reason we have come to wear clothes (at least for the more free-spirited ones among us). (EDIT: wording)