It spreads knowledge about the codebase
Since two people worked on the code, two people know intricately how it works, and can fix bugs in it without first having to spend time to learn the inner workings. Yeah, I know, in theory everybody should be familiar with everything, but in time-constrained practice you often have the same people fix bugs who wrote the code, keeping the others from getting to know the code of a feature. But even if only the people who wrote it know the code, if it was created by a pair, you already have two people who know it.
It spreads good practices
Even if you keep up with news about tools and practices, you can never know everything. Almost every time I pair, I learn something new – e.g. some eclipse keyboard shortcuts, a firefox add-ons for debugging, or a useful library class.
The code is better
You rarely write sloppy, “good enough for this one time” code – after all, the other guy will see what kind of code you write, and you don’t want to be embarrassed. And if you do, the other guy will point it out and correct it.
The design is better.
Two people have more ideas than a single person. If both are competent, they will agree to throw away the bad ideas, and combine only the good ideas of two people. As for APIs, two programmers think of different use cases, and make sure the API can handle them.
It avoids being stuck.
A lot of time is wasted when you’re stuck – situations where you’ve tried pretty much everything, and still can’t get your design or implementation to work. A second person will bring a fresh pair of eyes (and brain) and often think of exactly those things that you forgot. Or, in a case where you painted yourself into a corner, and have secretly felt that you should throw your efforts away as sunk costs and try a different approach, he will prod you to finally do just that.
It’s exhausting
I can program solo for long stretches of time, but when doing pair programming I usually take a break after two hours max. Paired sessions are much more intense, since they move faster, since (see above) you’re never stuck.
It’ only suitable for certain occasions
It’s a total waste to use two highly-qualified programmers to do simple, well-defined and understood tasks – examples: Defining a web form, setting up the base configuration for a project, or fixing selenium tests. It’s great, in short, for anything that is hard and new.
It’s expensive
A pair of programmers does move faster than a single programmer, but not twice as fast, so you spend more programmer time on a piece of code when doing pair programming. You do gain all the advantages mentioned above, though – so if it’s worth it really depends on the kind of work you do. In my experience, it’s best for integrating new developers in a team, and for anything that involves designing/implementing an API.