Since Reynolds (1878), the guiding principle of jurisprudence on issues of religious freedom vrs statutory law has been that free exercise is to be respected over statutory law with these provisos:
1) Free exercise can only be superseded by statutory law when the government has a compelling interest in enforcing statutory law.
2) Denial of religious freedom, when necessary due to a compelling interest, must be done by the least coercive means possible.
Regarding Davis, the government has no compelling interest in forcing Davis herself to issue the licenses. It could be done by a clerk in a neighboring county, which also would be less coercive regarding Davis.
The judge botched the law and violated Davis' constitutional rights. He needs to be removed from the bench, and prosecuted for violation of Ms. Davis' constitutional rights under color of law.