For it was of the LORD to harden their hearts, that they should come against Israel in battle, that he might destroy them utterly, and that they might have no favour, but that he might destroy them, as the LORD commanded Moses.
It was God's plan to make their hearts stubborn so they would attack Israel in a fight. He wanted to completely destroy them with no mercy, following his instructions to Moses.