Complex sentence: During invasions it helped shelter the local peasant population and the villagers also fought against the invaders and played an active role in defending the castle.
Split into simpler sentences: During invasions it helped shelter the local peasant population. The villagers also fought against the invaders playing an active role in the defence of the castle.