Yawning probably goes back at least to the first mammals, it's pretty hard-wired as a standard mammalian social cue signifying a calm and relaxed affect and being in the "rest and digest" parasympathetic mode. It's contagious across species, and even thinking about yawning makes you want to yawn!
Yes but humans have also co-opted it to mean something like “you’re losing my interest,” which seems funny to me. I wonder if there are more examples of instinctive behaviors being deployed sarcastically in humans.
Well, there's of course sarcastic smiling and sarcastic or scornful laughing, the "genuine" forms of both being partly involuntary responses. Another interesting reflex action that's been deployed socially by humans is clearing one's throat to politely request attention.