Earlier quoted context omitted.
The law isn't a series of "if... then..." statements. It's a collection of vagueries and categorizations that are wholly open to interpretation of when and who they apply to. Add to that, sometimes they are in conflict with each other. Judges jobs are to use they judgement.
It's not currently, but if we were able to use AI to generate laws in an objective and logically sound way based on general principles like "don't harm others or their property", we'd be much better off.
A major role of judges is specifically to not do that because there are circumstances that will not have been thought of at the time of a law being written, new laws will be written that interact in unforeseen ways with existing laws and/or common views on justice can change over time.
It may be technically illegal to destroy a person's property but no judge is going to convict someone who breaks down a person's front door because they heard someone crying for help inside. That's a simple example but there would have to be enumerable exceptions to every single law for an objective/logical AI to do justice.
Rather than try to enumerate the enumerable, we let judges judge.