Some of the strongest sources of political legitimacy are:
* Continuity with past institutions. For example ,the 98th Congress was legitimate because it succeeded the 97th Congress.
* Shared values and norms. For example, NATO suffered a huge loss of legitimacy due to the second Iraq war.
* Ability to identify public threat actors, and the ability to legitimately use violence (like incarceration) against them. For example, states with strong elements of organized crime usually suffer from low political legitimacy. However when organized crime becomes part of the state, legitimacy can increase (Hezbollah, the Chicago Outfit, and the Yakuza are examples).
* Self constraint by clearly defined norms. Some things just “aren’t done.” In America it would be scandal if a judge was elected because of the persons ability to fundraise. But that’s very common for ambassadors. For judges it’s just “not done.”
If a foreign power invaded and held elections, it’s unlikely the elections would be seen as legitimate, even if they were free and fair.
This is why both the US and Soviet Union were unable to hold legitimate elections in thier respective zones in Germany until the occupation ended.
Elections are really good example of how simulating an institution does not confer legitimacy.