Institutional Quality and Capital Inflows: Theory and Evidence