Since all instinctive behaviors have an evolutionary advantage or they would not have been retained for millions of years, chances are that this one too has helped us survive as a species.
A yawn is an instinctive behavior: You don't have to learn to do it, and yawns are even present before birth.