If we look at the text very carefully, we can see that the answer relates to the way in which Grendel is presented as being a demonic force opposed to the goodness of Christianity. Consider how this characteristic of Grendel is presented:
They could hack at Grendel
From every side, trying to open
A path for his evil soul, but their points
Could not hurt him, the sharpest and hardest iron
Could not scratch at his skin, for that sin-stained demon
Had bewitched all men's weapons, laid spells
That blunted every mortal man's blade.
Grendel's ability to cast spells and "bewitch" the blades of his opponents, combined with his description of being "sin-stained" clearly indicates that he is a force of evil and highlights his status as a villain and a chaotic enemy, which of course helps to present Beowulf as an agent of good as he battles against the might of evil, in the form of Grendel. Let us remember that this epic was originally written in a time when Christianity held sway, and thus the conflict between the pagan witchcraft represented in Grendel and the Christianity of the writer is presented partly through Grendel's ability to cast spells, which places him in the leage of the devil and evil.