This paper introduces the concept of institutional resilience based on a population game. Agents in an economy are randomly matched to play a coordination game with two strategies, cooperate and defect. A breach of contract can be adjudicated in court. Agents can update their strategy, which is modelled using the replicator dynamic. In this context, cooperation is defined as the informal institution, whereas the legal system (contract law) constitutes the formal institution. Institutional resilience is defined by how the formal institution of a functioning legal system complements the informal institution of cooperation in a dynamic way. In the wake of an adverse exogenous shock, the formal institution can prevent a total breakdown of cooperation in the population.