Society in the middle ages revolved around feudalism. Feudalism was a societal system where each person traded their goods or labor for protection - essentially a market for safety.
Peasants would trade their goods and labor to a local lord for protection in his castle in case of war. A portion of their harvest was taxed, and each year they had to help the lord harvest his fields. In return, the lord would keep a small force of men-at-arms who would protect his castle and the people.
The lord himself would trade his services, and those of his soldiers, and become a vassal of a greater lord. This greater lord would help all his vassals if they were in too much trouble for their small armies, and he could also call on his vassals to provide a levy of troops for himself if he decided to go to war.
At the top of the ladder was the king, to whom all lord were vassals. The king could call for an army, and each lord would request soldiers from his vassals, who would request soldiers from their vassals, and so on down the line, until a large army consisting of many small factions would be assembled. In this way, a large army could be assembled with a chain of command integrated from the start - no choosing or training officers before going to war.
The end result of this system was that everybody enjoyed some measure of security in trade for a loss of goods and labor. Many historians will also argue that the security also came at the cost of many freedoms, although this aspect depended entirely on the vassal and lord.