The law is an ass; is a phrase of English origin that Charles Dickens popularised in his book; Oliver Twist, 1838.
While an ass is an informal name for a Donkey in England, it also represents obstinacy and stupidity. And so, when the law is strictly applied without considering the common sense aspect of the matter, the law becomes an ass.