He committed no crime. In Frank Stockton's 1882 story, the young man (a courtier) is falsely accused of loving the king's daughter – a "crime" only in the king's tyrannical, semi-barbaric justice system.
The accused chooses between two doors:
The princess (king's daughter) knows which door holds which. She signals "right." The story ends before revealing the outcome – the central ambiguity that has sparked debate for over a century.
The "crime" is loving above his station. The trial-by-ordeal is the king's sadistic entertainment, not justice. The story interrogates jealousy, power, and the impossibility of knowing another's heart – leaving the reader to decide the princess's choice and the lover's fate.