Bible commentator Ken Collins suggests:
The trap is this: under the Roman occupation, the power of capital punishment was reserved by the Romans for themselves. All capital cases had to be referred to the Roman authorities and the sentence had to be approved before it could be carried out. So Jesus' enemies figured they could trap Him in a dilemma by presenting Him with a clear-cut case where the Jewish Law demanded the death penalty by public stoning. If Jesus deferred to the Romans, He discredited Himself as a Teacher of the Law. If He condoned the stoning, the Romans would consider Him an insurrectionist and put Him to death. Either way, they thought, He couldn't win. He would either lose His credibility or His life; either way, He would be silenced. 
As it turned out, Jesus simply turned what they were doing back on them. "Let he who is without sin cast the first stone." As the others left, only Jesus remained. He was without sin, but would not bring the punishment of the law against her, telling her instead to go and sin no more.