languages spoken by people display a dazzling variety of sounds, word patterns, and grammatical forms. The dominant explanation for this diversity is that languages drift apart as communities separate. The accumulation of random changes eventually produces languages that are mutually unintelligible. We argue that in addition to this non-functional process of drift, language change and diversification can be explained in functional terms as adaptations to social, demographic, and ecological environments in which the languages are learned and used, a proposal we call the linguistic niche hypothesis. We support our position with a series of agent-based models that serve as an existence proof for why language diversity requires adaptation. We next discuss empirical evidence for a link between aspects of socio-demographic factors, ecological factors, and grammatical structure which strongly suggest adaptation to be at work. One mechanism we focus on is language learnability: while all languages need to be learnable by infants, only some languages are further constrained by adult learning biases. Thus, languages which for historical reasons have adult learners adapt to be more learnable by adults. As a result, languages spoken in larger and more heterogeneous environments in which adult language learning is more likely to take place tend to be grammatically simpler than languages spoken in small homogeneous environments. The linguistic niche hypothesis outlined in this chapter, while still in early stages, promises to shed light on longstanding questions such as why there are so many languages, and why they differ so substantially from one another.