An Economic Theory of Democracy