Some posters have given the correct answer, generally, but some clarification might help.
The clerk is not being criminally prosecuted. The judge, using something called his "inherent power," has put her in jail for disobeying a court order (otherwise known as an injunction).
I don't know the specifics of the case, but from the current posture, the following is readily inferable: the plaintiffs in this case sued the county and its officials for denying them a marriage license, and sought an order from the federal court that the county clerk issue them a license. Federal law, specifically the Fourteenth Amendment, as capably noted by others, includes among many other rights a right to marry whomever one chooses, and recently was read to also a right to marry someone of the same sex. When you sue someone alleging a violation of your federal rights you get to go to federal court, again as noted, under laws called sections 1331 and 1983. The defendant, likely sued in her official and individual capacities, likely raised as a defense her First Amendment right (or a comparable statutory right) to be free from compelled religious exercise or association. She lost at the district court level, lost at the appellate court level, and lost in the Supreme Court. The Supreme Court remanded the case to the district court, which then held a contempt hearing. The clerk remained steadfast in her refusal, the judge did not like that, and he tossed her in jail for ignoring his order.
She would not have been able to claim qualified immunity as a defense, because the suit likely only sought injunctive relief, among other reasons.