Legitimacy and the Quality of Democracy