1. The officer was dispatched and had to investigate.
2. All Gates had to do was say "Yeah, I lost my key and had to break in(though why not call the Harvard maintenance people since they would come out?) and show his ID; end of situation.
3. Gates pretty much talked himself into getting arrested because of, from the sound of it, a combination of arrogance, looking for racial insult, and stupidity.
4. He probably shouldn't have been arrested.
Mind you, the way Gates acted he'd probably have filed a complaint, contacted a reporter, etc. anyway, because if you're looking for insult in everything you're going to find it. And bitch and whine about it.
Balko has a piece at Reason on how this is symptomatic of police making arrests they shouldn't as 'contempt of cop', which does indeed happen. They also use 'Disturbing the peace' and such as the excuse to arrest someone who annoys them for some other reason; it seems to be a favorite of officers arresting someone for legal open carry("It may be legal, but I won't let you get away with it" is the attitude). Yeah, it's often dropped, but in the meantime you've been arrested, handcuffed, searched, your vehicle impounded, and the whole thing costs you time, money and difficulty, and you can't do a damn thing about it most of the time, and that's exactly why they do it.
This has been around for a long time, but I think it was used much less in the past, generally in reaction to a percieved real problem instead of "Because I don't like you/it and I can." As much as anything, it's a problem directly related to many police being of the "I am a COP" attitude as opposed to "I am a Peace Officer who remembers Peel's Principles"; one will take charge of a situation and defuse it if at all possible, the other tends to see the 'Take charge of the situation' instruction as requiring them to be an aggressive, in-the-face offensive jerk(he won't see it that way, of course).
No, the officer probably shouldn't have arrested Gates; Yes, if Gates hadn't reacted VERY badly it never would have reached that point.