There is an entire field of mathematics dedicated to answering such questions and the answer is a lot more complicated than your simple quip. In fact the way most democracies are set up they are theoretically much less optimal than they could be and in some cases are as good as dictatorial systems because of susceptibility to being rigged. As usual wikipedia is a pretty good starting point:
https://en.wikipedia.org/wiki/Voting_system.