THE HISTORY OF THE PART OF THE WORLD WITH THE SHIRE IN IT
So there’s this kingdom in the North, called Arnor, and geographically it includes the Shire and all the lands around it, from the Grey Havens (on the western coast) to Rivendell in the shadow of the Misty Mountains in the east, and many miles north and south. This is before the Shire was founded, when the guys who ended up in the barrow-downs were alive and well. Also the guys who built the tower of Weathertop.
Centuries go by, and a king of Arnor dies without a strong single heir, which means the nation gets carved up into three kingdoms for the three sons: Arthedain, Cardolan, and Rhudaur. The latter two countries are jealous of the former, for having a larger share of the ancient magical treasures, control of Weathertop, Palantir, that sort of thing. They end up warring among themselves off and on for a few centuries, which only gets worse when Angmar gets in on the action.
Angmar is a region in the northeast of old Arnor which by the time Arnor is split into three has long been depopulated and devoid of interest, so none of the three successor-states claim it. A dark sorcerer arrives there, and recruits dissident men and enslaves orcs and trolls, and makes war upon Arthedain and Cardolan, intermittently allied with Rhudaur. The dark sorcerer in question was actually the Lord of the Nazgul, but no one knew this at the time. Eventually a force of Elves led by Elrond subdue Angmar, and things are mostly quiet for another few centuries.
At some point Hobbits wander in, mostly from the other side of the Misty Mountains, and ask the King of Arthedain at the time, Argleb II, for permission to settle in the Shire, which he grants. Then a plague depopulates most of Cardolan and Rhudaur. The Hobbits and the Arthedain survive the plague, but only barely.
Another few centuries go by, and then the Witch-King of Angmar pops up again, ooh! He attacks Arthedain and Arthedain is much weaker than it was prior to the civil wars and plague. The King of Arthedain at the time, Arvedui, evacuates with a palantir and flees to the arctic north, where he’s taken in by thinly-veiled Inuit analogs, the Lossoth.
Cirdan the Shipwright, the Head Elf in Charge over at the Grey Havens, hears about Arvedui’s troubles and sends a ship to fetch him, but it sinks on the way back, thanks to an evil (Sauron-created, presumably) storm. The Lossoth worried that would happen, and they had warned Arvedui, but enh, that’s what happened. So no more kings of Arthedain, and no more Arthedain, really. Angmar sacks it.
Arvedui had a son, who was in hiding in the wilderness, and he grew up to become Chieftain of the Dunedain, which is to say, Aragorn’s ancestor. From this point on, and we’re talking many centuries, the scattered Dunedain don’t live in cities, but in camps, and range around like rangers, and hunt and gather and take advantage of Elvish hospitality instead of farm and mine for themselves. Bree and Breeland were pretty much the only remnants of Arnor, by this point. Breeland isn’t even populated by ethnic Dunedain, but by immigrants who wandered north from further south (where things were even worse).
Meanwhile the Shire survives the destruction of the rest of Arthedain around it, which is a neat trick. They sent troops to support Arthedain against Angmar, believe it or not, and once Arthedain collapses they transition to self-government pretty effortlessly. Bucca of the Marish becomes the first Thain of the Shire, and the head of the Oldbuck family.
Things got pretty grey for a long time, as Aragorn’s ancestors failed to accomplish much and Elrond’s wife was carried off by orcs. She was rescued, but afterwards announced she was sick of Middle-Earth and sailed off to Valinor without her husband. The orcs in the mountains increased in number, and attacked the Shire, and were driven off by a militia led by Bullroarer Took, Bilbo’s great-great-uncle.
Eventually Aragorn was born, and grew up in Rivendell, and ranged around and then the events of the Hobbit and the Lord of the Rings happen.