Craig Conley, a scholar of magic, writes that the magic words used by conjurers may originate from "pseudo-Latin phrases, nonsense syllables, or esoteric terms from religious antiquity," but that what they have in common is "language as an instrument of creation."
Likewise, other magic words exist as part of a social contract, designed to express affection for another. Such words are magic not because of their effect on people (If they were, this would be simple manipulation, not etiquette) but because they make others feel better in context of the situation. For example:
Please should not be used for just any request, but a request that might be considered unreasonable without it. This is because it is used to reflect the knowledge that the asker understands the trouble involved in the request.
Thanks is used to show that the other person's actions are valued.
Sorry is perhaps more important than the first two, as it is used to express regret over one's actions. Without such regret, relationships often dissolve over time. Also, contingent on this idea is the promise of not repeating the action (a promise which may be difficult or impossible to carry out, which is why some people are reluctant to apologize).
In addition, an unofficial magic word may be added, since it follows a similar idea. The word Stay (not as it is used to dogs, but as the opposite of "Leave!") could be considered magic since it expresses the idea that the person is loved or wanted, and that they belong.