Likewise, an oath is obligatory in a claim before a judge when it is needed to ward off injustice. For example, if a man brings a false claim against an orphan’s property and the oath is required of the guardian, then the oath is obligatory in order to prevent the injustice that would be inflicted upon the orphan’s property.
An oath is prohibited if it concerns committing something forbidden or abandoning an obligation. For example, if a man says, “By Allah, I will not pray with the congregation,” or says, “By Allah, I shall certainly drink wine.”
It is recommended if the performance of a recommended act depends on it.
Likewise, it is disliked if the performance of a disliked act depends on it. The basic principle, as we stated at the outset, is that a person should not swear an oath except for a reason that calls for it.
The oath for which expiation is required if one breaks it is an oath sworn by Allah, by one of His attributes, by the Quran, or by the written copy of the Quran. Swearing by other than Allah is prohibited, and no expiation is required for it. ...........
His statement: “The oath for which expiation is required if one breaks it is an oath sworn by Allah.” The word “expiation” is derived from kafr (covering), and it indicates that there is a sin requiring expiation. That sin is the violation of the sanctity of that by which one has sworn through breaking the oath. For when you say, “By Allah, I will not do such-and-such,” its meaning is: by the right of the sanctity and veneration due to the one by whom I have sworn, I will not do this thing. Thus, if you do it, there is a violation involved. This is why Allah the Exalted called it an expiation. Yet, out of His mercy to His servants, Allah permitted them to break an oath by way of concession and ease; otherwise, the basic principle is that one must fulfill one’s oath.
This is why he said: “if one breaks it.” Ḥinth means sin, as Allah the Exalted says:
“They persisted in the great sin.” [56:46]