Social relations are embedded in material, cultural, and institutional settings that affect network dynamics and the resulting topologies. For example, romantic entanglements are subject to social and cultural norms, interfirm alliances are constrained by country-specific legislation, and adolescent friendships are conditioned by classroom settings and neighborhood effects. In short, social contexts shape social relations and the networks they give rise to. However, how and when they do so remain to be established. This paper presents network ecology as a general framework for identifying how the proximal environment shapes social networks by focusing interactions and social relations, and how these interactions and relations in turn shape the environment in which social networks form. Tie fitness is introduced as a metric that quantifies how well particular dyadic social relations would align with the setting. Using longitudinal networks collected on two cohorts each in 18 North American schools, i.e., 36 settings, we develop five generalizable observations about the time-varying fitness of adolescent friendship. Across all 252 analyzed networks, tie fitness predicted new tie formation, tie longevity, and tie survival. Dormant fit ties cluster in relational niches, thereby establishing a resource base for social identities competing for increased representation in the relational system.