Perhaps to immobilize the hands?
Likely part of the punishment was that your head was vulnerable and, as with the stocks, people could “join in” the punishment and toss garbage at you.
But, does this “punishment barrel” have any relation to the modern-ish “bankruptcy barrel” meme?