Our Illustrious Ancestors
A nation isn't just land and laws, it also requires a mythology. To be glued together as one, people need excuses as to why they are exceptional. Consequently, it's customary to trace one's ancestry to others who can be imagined to be more glorious. Thus the Romans traced themselves back to Troy, Spanish aristocracy traced itself to the Visigoths, and the Nazis to the conquering Aryans, whom they imagined to look a lot like themselves.
The word Aryan was the name the Vedic peoples of India gave themselves, and was also used by Persians as an autonym, whence the modern word Iran. Its European roots date to the discovery that Persian and Sanskrit were closely related to most of the modern languages of Europe. Originally a linguistic term for the languages we now call Indo-European, it took on a racial implication under the influence of white people's desire to convince themselves that they were superior to everyone else (the inconvenient fact that those original Aryans didn't seem to be quite white was explained as a side effect of racial mixing.) The consequent racist bullshit, widespread among whites, and culminating in the Nazi outrages, poisoned the term, so now we mostly use the more descriptive "Indo-European."
Six thousand years ago, approximately, the original speakers of proto-Indo-European (those so-called Aryans) probably constituted a few thousand pastoralists in Central Asia. Since then, their languages have spread across the globe, and are official languages in much of the territory of every continent, spoken by nearly half of all persons. They were illiterate and itinerant. We don't see their languages in the historical record until they encounter more civilized and literate peoples. Which invites the question of how they swept so many other languages away.
Despite their illiteracy, they could manufacture bronze, and, most importantly, had domesticated the horse, giving them tremendous mobility. Our first example of the languages of India, for example, comes from the Middle East, in a book on chariot warfare written by an instructor imported from India.
So how does a language come to replace all it's competitors? We can only guess at much of the history, but we have genomic evidence that the invaders of Europe displaced many of the previous peoples, but ultimately (a thousand years later) mixed with them. In the case of the Americas, wholesale extermination played a big role, especially in the North. In other cases, economic factors seem to predominate. Pastoral societies usually have more social flexibility, so a person who wants to get ahead learns the language of opportunity. We see an analogous process today, where English is the language of science and commerce, so that it pays a young Japanese, Chinese, Indian and others to learn English.
Except for genomic part, the above is adapted mainly from In Search of the Indo-Europeans, by J. P. Mallory.