I'm uncertain why it was voted to close after my edits. How can I clarify or improve How did 'despite' semantically shift to signify 'without being affected by something'??
You could, as the closure screed suggests, clarify what you're asking. At present the question gives several citations to show that despite meant and means 'in the face of' or 'no matter what can be done to prevent' and one to show that it also has a sense of "notwithstanding". So far so good, but you then see that notwithstanding has a meaning of "without being affected by" and find some contradiction. I don't know why you say that "'scorn, contempt' is the polar opposite of 'without being affected by'" and you give no reason for the belief. You also assume (or appear to assume) that if one meaning of one word is the same as one meaning of another word, the two are synonyms, or in other words that equality is transitive among English words; the falsity of this is well-known to anyone who has studied the language. Finally, I myself have literally no idea what you mean by "What semantic notions underlie 'scorn, contempt' and 'without being affected by something'?" beyond the dictionary entries you have already cited. You obviously have a question in mind, and it may be a good one; but at present there is no way to tell.
(One possibility that occurred to me while writing this is that you think "without being affected by" in the definition is the same as "without having any feelings about". This would not be entirely unreasonable, since both could be expressed as "without caring about"; but it would be wrong.)