The medieval castle moat served as a formidable form of defense against an attack from the outside.
The moat made it impossible for an enemy to scale the walls or to directly assault them.
Rather, the attackers either had to wade through the water-filled moat or make their way at a very slow pace through the dry moat.
In both cases, the defenders on castle walls had ample opportunity to launch their attacks on the enemy approaching at a slow pace and force the enemy to suffer significant losses.
Even if the enemy managed to reach castle walls despite a moat, it took significant time and resources.
This gave the defenders an opportunity to devise an effective strategy to defend the Castle!