It turns out there are real performance benefits to working out with a buddy. But aside from motivation from moral support and distracting you from the pain, those improvements can also come from another interesting source: insecurity.
Studies looking into both cardiovascular exercise and strength exercises (like these two, published in the Annals of Behavioural Medicine and Journal of Exercise Psychology) have consistently found that exercising with a partner tends to make you work harder and longer, especially if you're buddied up with someone slightly better than you.
The phenomenon is attributed to what psychologists call the Köhler effect: when individuals push themselves harder in a group setting (be it consciously or subconsciously) to avoid being the weakest link. If you've ever accidentally stumbled into a group fitness class filled with people who are way fitter than you, you'd definitely understand.
That said, a workout buddy has its own drawbacks that aren't apparent in a lab setting. So before you trawl Craigslist for a gym buddy (which is legitimately a thing) ask yourself if you're willing to subject yourself to another person's schedule, and if they're not free would you use their unavailability as an excuse for your laziness.