Extreme joy, anger, etc, brought on by a situation that causes one to be "out of one's mind" with that emotion.
"Beside" was formerly (15th through 19th centuries) used in phrases to mean "out of a mental state or condition, as 'beside one's patience, one's gravity, one's wits'" (Oxford Engl. Dict.), and that use survives only in "'beside oneself': out of one's wits, out of one's senses."
A modern phrase invented by a millennial of telling somebody to be humble and taking a crystal clear look at themselves before passing judgement and/or being critical towards others.