Normally, it is an Issur Deorayta (Torah Prohibition) to erase Hashem's name - לא תעשון כן לה׳ א–לוקיכם. However, by the Sotah we do erase Hashem's name. Is this working using the methodology of עשה דוחה לא תעשה– that a positive commandment overrides a negative one, or some other mechanism? If it is עשה דוחה לא תעשה, is it הותרה or דחויה– completely permissible or should we try to avoid it as much as possible? Does anyone talk about this? Thanks so much in advance.
The Beis Efraim (Yoreh Deah § 61 s.v. ולענ"ד) by Rav Efraim Zalman Margaliyos (18th century) brings the Tashbetz (1:2), who says that we can't learn from erasing the Sotah's megillah to other cases, as it's a gezeiras hakasuv, a decree of the writ. The Beis Efraim asks on him that if it's a gezeiras hakasuv that the mitzvah permits one to override the prohibition of erasing Hashem's name, why didn't the gemarra in Yevamos 3b learn from here the source for aseh docheh lo sa'aseh?
First he wants to answer like Tosafos to Yevamos 3b s.v. לא תעשה says, that something whose mitzvah involves transgressing something, and there's no other way other than this to fulfill the mitzvah, is in a category on its own. It's not the same as aseh docheh lo sa'aseh, where sometimes it's possible to fulfill the mitzvah without transgressing anything. Tosafos says it by Yibum, which by definition is a mitzvah involving a normally forbidden relationship. Since it's "mitzvaso bekach", it's not the same as a regular aseh docheh lo sa'aseh, like bris milah on a tzara'as blemish. The Beis Efraim says the same idea would apply here.
He ends up rejecting this approach and then wants to say (s.v. ועכ"פ) that this question is a proof to his understanding of the prohibition of erasing Hashem's name. He says it's only prohibited in a destructive fashion, like we're commanded to with destroying idols. However, if your intent is for a positive purpose, there's no prohibition at all1. Therefore, aseh docheh lo sa'aseh has no relevance by the Sotah, since in her case there's no prohibition. Since the whole reason the person is erasing Hashem's name is to fulfill His will, this isn't considered a destructive act of erasing His name.
He then brings that the Teshuvos Rema (100:10) says this exact same explanation.
Howevever, the Minchah Chareivah (Sotah 14b s.v. כסבר מקשה) by Rav Pinchas Epstein (20th century) understood that the Tashbetz holds that the Sotah's megillah does in fact work through aseh docheh lo sa'aseh. However, for whatever reason it's unique to Sotah and can't be learned elsewhere. He then wants to suggest that perhaps this is the explanation for the dispute between the Rabbis and Rabbi Shimon in Sotah 14b.
1 On a related note, someone asked Rav Asher Weiss what to do about a bathroom where a deranged person wrote Hashem's name over all the stalls. He said it's permissible to erase the names, as leaving them in that state is disgraceful to Hashem. I don't remember but it could be he was invoking this understanding of the Beis Efraim.
It seems it is not a mechanism per se but rather based on a logical kal vachomer (a fortiori) that ultimately revolved about maintaining a sense of peace and harmony between a husband and wife.
The Gemara in Nedarim 66b writes:
ההוא דאמר לה לדביתהו קונם שאי את נהנית לי עד שתטעימי תבשילך לרבי יהודה ולר"ש ר' יהודה טעים אמר ק"ו ומה לעשות שלום בין איש לאשתו אמרה תורה שמי שנכתב בקדושה ימחה על המים המאררים בספק ואני על אחת כמה וכמה
§ The Gemara relates: There was a certain person who said to his wife: Benefiting from me is konam for you until you have given Rabbi Yehuda and Rabbi Shimon your cooked food to taste, so they can see for themselves what a bad cook you are. She brought the food to them, and Rabbi Yehuda tasted it, without concern for his honor. He said: This is an a fortiori inference: And what can be seen, that in order to make peace between a man and his wife, the Torah said: My name, that is written in sanctity, shall be blotted out in the waters that curse, as the words written on a scroll, including the name of God, were blotted out during the ceremony of preparing the water that a sota would drink. And this is so even in a case of where it is uncertain if this will bring peace between them, as she may or not be guilty of adultery. I, all the more so, should waive my honor in order to bring peace to this couple. (Sefaria translation and notation).
Similarly it is brought down in the Yerushalmi in Sotah 1:4 a story with a similar end deduction. It relates the story about a disgruntled husband and his interaction with his wife. This wife went to hear a shiur from Rabbi Meir every erev Shabbos. On one occasion the shiur lasted much longer than normal and she returned home to find that the lamps in her home had burned out. Her husband angrily asked where she had been, and in his rage said he wouldn't allow to enter the house until she spat in Rabbi Meir's eye. Rabbi Meir heard about the situation through ruach hakodesh and pretended to have a medical problem with his eye. He promptly announced that anyone who knew of a special prayer to whisper over the eye should come forth. Her neighbours advised her that this was her opportunity - she should whisper something and then spit in his eye quickly afterwards. When he approached her and he asked if she had a cure, she couldn't bring herself to do it out of kavod for the revered sage. He responded that she should spit in his eye seven times. Upon her doing so, he told her that her husband said she spit in his eye once, but she did so seven times! His students saw this as a real affront to their Rebbi and were horrified. However, the Yerushalmi concludes:
אמר לון ולא יהא כבוד מאיר ככבוד קונו. ומה אם שם הקודש שנכתב בקדושה אמר הכתוב שיימחה על המים בשביל להטיל שלום בין איש לאשתו. וכבוד מאיר לא כל שכן
He said to them, should Meir's honour be like the honour of his Creator? If the Holy Name which is written in holiness should be erased in the waters [i.e. in the case of sotah] in order to restore peace between a husband and his wife, how much more Meir’s honour?
Thus, such is Hashem's love for matrimonial harmony, He will seemingly forgo His honour to ensure that this is done.
As the Netziv perhaps best encapsulates:
You shall be absolved. The Kohein advises her to drink to absolve herself, and not be concerned about the erasing of Hashem’s name, for this is His will and His honor....(Sefaria translation)