The ultimate purpose of government is to provide good government. This means: to watch over a society so that it allows those who live in it to get through their lives as happily and appropriately as possible. Thus the government is in charge of providing safety, and apart from that, should allow the citizens it rules the greatest possible personal freedom.
The purpose of government is not to have been democratically elected. Yes, good government should represent the interests of those that are governed. But some forms of democratically elected governments do often not achieve this. Take, for example, directly elected populist presidents.
A democratic system in which presidents are elected directly often does not produce rational results (results that would objectively represent the interests of the electorate). Such systems typically favor populist candidates. To get elected, populist candidates appeal on instincts and emotions. The easiest emotions to address are those of envy and hate.
Populist candidates typically present clear pictures of enemies. They often are elected on the basis of what they oppose, not of what they support.
There are many variations, in which this tune can be played. It can be anti a certain ethnicity, anti foreign, anti a successful minority, anti other religions, anti immorality, anti liberty for others.
Such agendas typically are not in the best interest of those governed, because their appeal to the broad base of the electorate only lies in the assumption that only others will suffer from the hate policies, and that the individual supporter of a hate populist will not be affected.
That can be a dangerous error, because governments that are popular because of their opposition to certain "enemies" of society develop their own momentum. When they got rid of one enemy, they will need another one, and than another one, and another one. Such policies impossibly serve a society as a whole, and sooner or later, even the initial supporters of a populist will suffer.
Now, this, objectively, cannot be in the interest of the initial supporter (even if we don't address the point that the populist government from the beginning only represented its initial supporter's emotions of hate and envy).
Populist governments are a nuisance, and anybody who can afford it is advised to get out of harm's way early enough.
To avoid "populist" governments, it is best not to have direct elections. Definitely, a country's president should not be elected directly. Party-based elections are already a bit better, though they are no guaranty against the populist pest.
The most level-headed governments are obtained through indirect elections. The electorate chooses representatives that sit in a local body. These representatives elect one of their members to sit in a regional body. The members of the regional body elect one or several of their peers to represent them in a national body. And the national body elects a chief executive.
Such indirect democracy is hard to manipulate by populists, and it will result in a government that represents a wide range of interests, not just the emotions of hate and envy of the lowest (and therefore widest) strata of a social pyramid.
