What must be demonstrated for the election of government officials to be perceived as legitimate?

What must be demonstrated for the election of government officials to be perceived as legitimate?