Feudalism began with people joining together in response to problems like these, danger from foreign invaders, the lack of a common currency or trade, and food shortages. So therefore they created a "system" called the Feudal System that would help them.
In most of medieval Europe, society was dependent on the feudal system, which was when a king or lord ruled large areas of land. To protect his land from attacks, the king gave parts of it to local lords, who were called vassals. In return, his vassals promised to fight to defend the king's land. If people wanted safety and defense, they had to live in a manor. People in the middle ages created small communities around a king or a lord. Most people lived in a manor, which consisted of a castle, a church, a village, a mill, and the surrounding farmland. These manors were isolated with huge walls, with rare visits from outsiders like merchants. Each manor was self-sufficient, which means that they made everything them selves, like food, clothes, and weapons. Self-sufficiency was very important in these days, because if they weren't able to grow food for them selves, there was no other way for them to get it.
The feudal system worked fine, because everyone had what they wanted and needed such as protection and food. For a peasant it was a very harsh life, if they were born there, they would probably stay there their whole life. Peasants had no rights to do anything except working for their lord, they paid very much for the right to live and grow crops on the lord's land.