Economic development and endogenous quality of institutions