Why do people feel shame? Meaning the kind of shame specifically related to exposing 'private parts'.
Where does it come from (i.e. social factors due to upbringing, inherent in our genes etc.)? What is its evolutionary purpose?
Probably a cultural effect
In many tribes, people are naked. Also, the naturist movement is very popular in the western culture and they don't feel shame. In northern Europe, it is common to be naked in spas.
I would guess it is mainly a cultural effect and there is little heritability for this trait. I doubt you'll find a study on this particular question, so the best one can do is just to formulate a guess here.
If you don't quite understand why I talk about heritability here, then you should have a look at Why is a heritability coefficient not an index of how “genetic” something is?. In layman terms and in vague terms, I meant that there is probably little role of genes to explain why we feel naked.
Yes, but let's assume it was selected for...
If we were to assume that feeling of shameful in front of nakedness had been selected for, one may hypothesize that it could be due to sexual selection, where rich and wealthy wear clothes. It could also be due the social presssure of showing off what you are worth as sexual body parts are likely under strong sexual selection as well.