here are three kinds of law: natural, manmade and revealed. There are rules... plain common sense rules that shouldn't even have to be written down, taught or defended. Universally, people with common sense know by sheer conscience that some things are immoral. Then, below that, there are rules which are made by men. However, there are certain rules which have been handed down to us by God Himself. These rules are perfect and supreme. They supersede and eclipse all other laws. The Bible stands above every other authority.
What happens when a man finds that he is in a position where no matter which way he turns he'll be violating one or more of God's laws? Were it not for the fall we wouldn't have this problem, but ever since then, our race has faced it often. While God's laws are never self-contradictory, we can surely put ourselves into circumstances where there's no perfect option; just better or worse options.
What was Ezra to do when he found that the remnant of the Jews (who had returned to Judah prior to his arrival) had freely intermingled with the Canaanites? It couldn't be undone... or, could it? Whatever the solution, the option of idolatry had to be removed. So, when Ezra saw Jerusalem in disobedience and realized that the exile of the nation had not persuaded them to abstain from marrying idolatrous gentiles, he was livid (Ezra 9:1 & 14). He was quite literally pulling his hair out in frustration. He was ashamed even to go to God in prayer for these rebellious people (Ezra 9:6). But, he did it anyway.
I'm not espousing moral relativism. I'm an absolutist. Truth is concrete and eternal, not fluid nor subjective. However, in this situation, nothing was more important than stopping the pollution of the Jewish faith. Ezra was at a loss for words.