Hint, it's not 'the best possible'. Nor does it put 'the best guy' in charge.
First I need to say, this is about a real democracy, not a sham one. If there is not at least two political parties that have a reasonable chance of winning the election, it's not a democracy.
There are in fact certain advantages to other forms of government. They don't have costly elections, often the next leader is known long before he takes office - so he can study and learn how to be a better leader. In addition, because the next leader is known, he has no reason to try and cheat to gain power, which means he won't have as much practice or reason to cheat after he gains power. Also, to misquote Trey Parker/Matt Stone, our experience with Democracy is that "It's always a choice between a turd and a douche".
There are in fact studies that demonstrate that Democracy tends to pick leaders only slightly better than average. (Source).
But Democracy has been proven time and time again to be better than other forms. Even if the democracy results in a turd (or a douche) it is better than a coup that results in a 'good leader'.
Democracy works for six specific reasons:
1) It's often about ideas, not people. The nature of democracy means people have to band together and create a distinct sub-culture/viewpoint, called a political Party. You often vote for a party, not for the person. This is important because the party can't lie about their views. If you try, then you attract people that believe your lies, and the party gets slowly transformed into actually believing what they claimed they believe. (which is why Ron Paul has been gaining ground each year in the GOP)
2) It forces the leader to pay some attention to what the population wants. Unlike North Korea, where they can ignore the population's demand for food and spend money on nuclear bombs, we have to at least look into what people want and try to answer there needs.
3) It tends to stop people without social skills from taking power. You need good social skills to win an election and running a country is mostly about social skills - getting people to do what you want them to do. Leadership is about LEADING, not thinking. In particular, diplomatic relationships are all about social skills.
4) Democracy usually trains multiple people. The advantage of having multiple people train for leadership is that you always have a backup. While they don't get the 'from birth' training that a monarchy offers, this way if one of them dies, another one is ready and willing to take over.
5) The adversarial nature leads to active, strong investigation of candidates. Of course, that requires that people believe the opposition and care about the infractions, otherwise you get Berlusci in charge of Italy. If corruption is assumed, or considered acceptable, this doesn't happen or matter.
6) You get what you deserve. If some douche gets elected, IT'S YOUR OWN DAMN FAULT. Frankly, sometimes people deserve a turd (or a douche) leading them. Experience is the best teacher. If you vote in a douche, maybe next time (assuming the douche doesn't stop all elections), you will learn your lesson and not vote for them again.
Democracy's main weakness is how do you start a good one. When people come from a corrupt culture, then often good people trust corrupt men, if for no other reason than the absence of honest men in politics. At heart it comes down to whether honest democracy is publicly valued enough. If so, it can handle a moderate level of corruption - as long as they think of themselves as honest. Then they can raise up successively less corrupt generations of politicians and in 100 years, you can work your way to a real honest government.
If on the other hand, the culture falls on the other side - with honest democracy valued less than success, money, or religion, then it will slowly become worse and worse, until an outright dictatorship takes over, often leading to a revolution - if only after the dictator's death.
America was incredibly lucky to start with George Washington - a man with the strength of character to reject kingship and then step down after but two elections. Think about what could have happened if our first leader was an Andrew Jackson, or a Richard Nixon, both of whom thought they were above the law. We very well might have become a Monarchy.
Democracy takes a huge amount of character to start - but they tend to be improve if they make it past their twenties.