In medieval Europe, it was common for animals to be put on trial and sentenced to punishment as if they understood the proceedings. Livestock and wild animals would be tried for assault or murder of a human, insects and rats were prosecuted for destroying crops, and livestock could be put to death for bestiality along with the human perpetrator (although a beast could prove innocence with witnesses to its virtue). There were unspoken reasons behind these shenanigans, in the days when the separation of church and state was nonexistent. The church could lay blame for bad events on people or animals, and take credit for doling out justice.
Animal trials certainly solidified the church’s power, but they also made sense of an unknowable world by turning freak accidents into understandable events, with guilty parties and paths to justice. Our grain stores are gone because God is punishing us, or, alternatively, because Satan is toying with us; we must atone and pray. The pig killed my child because it is a common criminal; it must be punished. In this sense, animal trials were not unlike that other great, barbaric version of rudimentary legal justice: the witch hunt, which also reckoned with inexplicable phenomena by targeting scapegoats. Indeed, Evans writes, during witch hunts animals were often punished alongside all those single women and healers, in keeping with the belief that Satan commonly possessed creatures like goats, ravens and porcupines.