I know shit is generally considered vulgar swearing in any context, while crap (though it's normally used as a swear word) is often used and allowed in decent contexts.
How did this happen, since they both refer to the same thing?
English Language & Usage Stack Exchange is a question and answer site for linguists, etymologists, and serious English language enthusiasts. It only takes a minute to sign up.Sign up to join this community
Crap is a recent word, an old word for 'chaff' that became a euphemism for shit in the 19th century. It became associated with the Crapper brand of flush toilet and has held on since. It's what George Carlin calls a "two-way word", in that it has a non-taboo meaning as well: "You can prick your finger, but you can't finger your prick". Then there is the dice game called "craps", where losing is called "crapping out". Shit has none of these ramifications; shit is just shit.
The distinction between proper words, euphemisms, and vulgar words is practically always about the specific word, not the meaning. And the acceptability of specific words changes over time. The whole reason that euphemisms exist is to provide an acceptable replacement for some rude term, because it's sometimes necessary to refer to things. So while we would generally prefer to avoid talking about defecation, if you do have to say it you should choose the less vulgar term.
Why does it matter? Choosing words properly is considered a signal of culture. Watch My Fair Lady for a classic demonstration.