Well, what happened is that when the Roman Empire was in its final days, people started fleeing the cities for the countryside, since the cities were big targets for barbarian invasion. For hundreds of years, a major part of the Roman economy were latifundias, which were basically large plantations owned by a wealthy Roman (who might live on the property, or who might have an overseer that ran it while he lived in the city). They often had slaves to work them, but sometimes had free laborers called coloni. Coloni became more common the closer you get to the end of the empire. So, in order to escape the dangerous cities, many ordinary Romans fled and tried to hook up with a Roman patron who owned a latifundia. If the citizen owned some land, he could join it to the latifundia in an arrangement with the patron in exchange for protection. These people eventually evolve into the first peasants. If he had no land, he could offer his labor instead. These people eventually evolve into the first serfs. Their resources were pooled, and they would now live off the land and use whatever excess money and resources there was to build a fortress to protect them from barbarians, scavenging neighbors, or later, Vikings. They would also hire a few soldiers or mercenaries to serve as law officers, see to the acquisition or creation of weaponry, and organize the defense of the fortress. These became the knights. When the central authority of Rome finally collapsed in 476 AD, these local lords then gained de facto power since there was no longer any government left in control of Europe.
In other areas, barbarians managed to set up regional kingdoms that lasted for a while. The most famous would be the Visigothic kingdom of Spain and southern France that lasted from about 476 AD to 711 AD. Clovis also set up the Merovingian Dynasty (of the Franks) in France around 500 AD. However, most barbarian kingdoms suffered from a serious legal problem in that they didn’t believe in primogeniture, which is where the eldest son inherits everything. They believed that all of their sons should inherit everything equally. Unfortunately, that also included lands, and so anytime a king would finally establish a large territory, he’d die, and the kingdom would have to be broken up into two, three, or four more kingdoms for the children, which in turn would be broken up for their children, and so on, resulting in the fragmentation of political authority once again. This finally ended with Charlemagne. Although he DID let his three sons inherit land equally from him after his death, he also set up the Treaty of Verdun, which finally established primogeniture in Europe. At his height, Charlemagne had virtually reunited Western Europe, but when he died, the three sections it broke up into become the basic earliest forms of France, Germany, and Italy. Spain was then taken over by Muslim invaders in 711, and they established a highly successful, advanced, and unified kingdom there until 1492.