Repeated interactions and contractual agreements are examples of different ways of organizing interactions in social and economic life and can foster cooperation in social dilemmas. Thus, when involved in social dilemmas, actors have incentives to form long-term relations with repeated interactions or to enter into contractual agreements. We analyze theoretically and experimentally the effects of repeated interactions and contractual agreements as well as their endogenous emergence. In line with earlier evidence, both ways of organizing interactions are found to foster cooperation. Our key contribution is twofold. First, with respect to theory, we derive conditions for investments in social organization. Second, empirically, we find that such investments are more likely when the costs are below a threshold that follows from a parsimonious game-theoretic model assuming equilibrium behavior, self-regarding preferences, and complete information. We find less experimental support for two additional conjectures on investments that are based on reasoning more in line with behavioral game theory.