They served as forts to defend different areas from attack and conquest.
Food, cloth, jewelry. Food from the butcher, cloth from the various trading with imports and exports and jewelry from artisans who create ceremonial pieces for the noble class. Depending on which time period you are referring to middle ages during dark ages the church had the power and the money. During the renaissance nobles and class elite businessmen held the money.
There's security guards in and out the castle and there's no need to know who lives in it.
Feudalism
The Catholic church was the primary force in the middle ages and the other force was the need to stay alive which became a feudal society.
People felt the need to visit especially holy places, as they still do e.g. Lourdes.
This question needs to be expanded. What having to do with the middle ages?
the middle ages
The original message was being lost in all the religion.
Land and serfs.
for farming
Some weren't soldiers, and needed protection for a lot of reasons, like anarchy during wars and periods of migration.
what does a 18 year old boy need to look for in a relationship or looking for a girl to start a relationship with