I think if you are considering what makes governments legitimate that it has as much to do with due process, legal controls and the division of powers within a state as democratic elections and popular sovereignty or representation.

However, I believe that legitimate authority is a much more organic matter, important are order, origin, endurance, particularly as those things relate to obligatory reciprocity, unspoken and sometimes unacknowledged expectations of mutual benefice/aid. After which I would say that legitimacy is also clear by its abscence, people know an abuse of trust, power etc. when they see, hear or experience it.

These conventions arise primarily as a consequence of primary (the family) and secondary (the neighbourhood, community, culture etc.) socialisation and/or the deterministic effects of genes and environment contributing to individual development, social cognition etc. I think its possible to deconstruct how these conventions in turn have to operate at the behest of the status quo or operate in myriad unjust or imperfect ways but the reality is they operate, they fashion norms, mores and practical insights which anyone ignores at their peril.