It's more of a philosophical question, isn't it?
Before the trial you can not know if someone is guilty or not. Executing them would be lynching, arbitrary decisions about life and death was more or less what they were on trial for.
Just to clarify, are you asking why a trial was necessary?