John Gill faced a controversy in his day (as Christians have faced in every generation) as to whether or not good works are necessary for salvation. He had a quite clear answer.

It may be proper next to inquire what is the meaning of the word necessary, and in what sense good works are so. That they are necessary to be done, or ought to be done, by all that hope to be saved by the grace of our Lord Jesus Christ, is readily granted; but not in point of salvation, in order to that, or with a view to obtain it… True indeed, I cannot say that good works are necessary to salvation, that is to obtain it; which is the only sense in which they can be said with any propriety to be necessary to it, or in which such a proposition can be understood; and which I charge as a Popish and Socinian tenet, and hope I shall ever oppose, as long as I a have tongue to speak, or a pen to write with, and am capable of using either… Nor, lastly, are they necessary to the consummate enjoyment of salvation in heaven, no, not as the antecedent to the consequent; that is, as an antecedent cause to a consequent effect, which is the easy, common and natural sense of the phrase; for who can hear of an antecedent to a consequent, unless by way of illation, but must at once conceive of that consequent as an effect depending upon the antecedent as a cause? Wherefore if good works are antecedent to glorification as a consequent, then glorification must be, and will be considered as an effect depending upon good works as its cause. And as it will be difficult to fix any other sense upon the phrase, and persons are and will be naturally led so to conceive of it, this, and this alone, is a sufficient reason why it ought to be rejected and disused… I readily own, that good works are necessary to be performed by all that are walking in the way to heaven, and expect to be saved by Christ, and glorified with him, who are either capable or have an opportunity of performing them; but then they are not necessary as causes, conditions, or means of procuring glory and happiness for them; nor are they necessary as the antecedent to the consequent, to pave their way to heaven, to prepared and make them meet for it; or to put them into the possession of it… THE NECESSITY OF GOOD WORKS UNTO SALVATION, CONSIDERED: OCCASIONED BY SOME Reflections and Misrepresentations of Dr. Abraham Taylor, in a Pamphlet of his lately published, called, An Address to young Students in Divinity, by way of Caution against some Paradoxes, which lead to Doctrinal Antinomianism.

Note that Gill’s position is charged with Antinomianism.

One of Gill’s points is that regardless of how much a theologian tries to qualify his use of the phrase, it should be avoided because of what it inevitably communicates to those who hear it. He mentions that Melanchthon faced this issue in his day in what is called the Majoristic Controversy.

This was occasioned by George Major (1502-74), professor at the University of Wittenberg. Major taught that “good works are necessary to salvation” and that “it is impossible for a man to be saved without good works.” He was attacked especially by Matthias Flacius.* Before this, Flacius had attacked Major because he had subscribed to the Augsburg Interim* (1548) in which the sola had been omitted in the phrase “sola fide justificamur.” In the controversy Justus Menius sided with Major, both of them contending that faith alone justifies, but that faith is not present without confessing and persevering. In the seven propositions of the Synod of Eisenach (1556), Menius repudiated the proposition “good works are necessary to salvation.” Major maintained that “good works are necessary.” Nicholas von Amsdorf* opposed Major, saying “good works are harmful to salvation.” Article IV of the Formula of Concord* (1577) repudiated both Amsdorf and Major, teaching that good works should be excluded from the question concerning salvation and the article about justification, but that regenerate man is bound to do good works. https://www.biblicaltraining.org/library/majoristic-controversy

Gill explains:

The first among the reformed divines that vented it, was George Major, contemporary and familiar with Luther and Melancthon: He has been represented by some, from whom one should not have expected to have had such a character of him on this account, as satelles Romani Pontificis, a person employed by the Pope of Rome; a tool of the Popish party to create divisions and disturbances among the Reformed. The Papists finding they could not maintain with success their notion, that good works were meritorious of salvation, instead of the phrase, meritorious of salvation, substituted the other phrase, necessary to salvation, as being a softer one, in order to gain upon incautious minds; when one and the same thing were designed by both. And this man was thought to be the instrument they made use of for this purpose. But however this be, certain it is, that the broaching of this doctrine by him gave great offence, and occasioned much disturbance. The writer of his Life intimates, that the consequences of it gave Major himself some concern; and that he declared in so many words, that “whereas he saw that some were offended, for the future he would no more make use of that proposition.” Among the chief of his opposers was Nicolaus Amsdorfius, who in great heat and zeal asserted, in contradiction to Major’s notion, that “good works were hurtful and dangerous to salvation ;” a position not to be defended unless when good works are put in the room of Christ, and are trusted to for salvation: But it is not doing of them, that is or can be hurtful to salvation, but depending on them when done. This controversy raised great troubles in the churches and gave Melancthon a good deal of uneasiness; who at first was ensnared into the use of the phrase, though he afterwards rejected it, as improper and dangerous. Amsdorfius did not deny that good works were to be done, but could not be prevailed upon to own that they were necessary. Melancthon at length allowed that “good works were not necessary to salvation;” nor did he dare to assert it: “For these reasons,” says he, “we teach that good works; or new obedience, are necessary; yet this must not by any means be tacked to it, that good works are necessary to obtain salvation and eternal life.” In his answer to the pastors of Saxony, he has these words: “Nevertheless, let us not use this phrase, good works are necessary to salvation.” And, in another place, “Verily I say, that I do not make use of this phrase, good works are necessary to salvation; but I affirm, that these propositions are true, and properly and without sophistry thus to be declared; new obedience is necessary, or good works are necessary; because obedience is due to God, according to that saying, Debtors we are.” Now these were the sentiments, and which are exactly ours of the great Melancthon, that peaceable man, who never was charged within running into extremes in controversy; his greatest fault, and which has been complained of by some of his friends, who have had a great regard to him and hi is memory, was, that he was for composing differences, almost at any rate, sometimes, as was thought, to the injury of truth, and with the hazard of losing it.

The Formula of Concord addressed the Majoristic Controversy:

1] A disagreement has also occurred among the theologians of the Augsburg Confession concerning good works, one part employing the following words and manner in speaking of them: Good works are necessary for salvation; it is impossible to be saved without good works; likewise, no one has been saved without good works; because, they say, good works are required of true believers as fruits of faith, and faith without love is dead, although such love is no cause of salvation. 2] The other part, however, contended, on the contrary, that good works are indeed necessary; however, not for salvation, but for other reasons; and that on this account the aforecited propositiones, or expressions, which have been used (as they are not in accord with the form of sound doctrine and with the Word, and have been always and are still set by the Papists in opposition to the doctrine of our Christian faith, in which we confess that faith alone justifies and saves) are not to be tolerated in the Church, in order that the merit of Christ, our Savior, be not diminished, and the promise of salvation may be and remain firm and certain to believers… 22] But here we must be well on our guard lest works are drawn and mingled into the article of justification and salvation. Therefore the propositions are justly rejected, that to believers good works are necessary for salvation, so that it is impossible to be saved without good works. For they are directly contrary to the doctrine de particulis exclusivis in articulo iustificationis et salvationis (concerning the exclusive particles in the article of justification and salvation), that is, they conflict with the words by which St. Paul has entirely excluded our works and merits from the article of justification and salvation, and ascribed everything to the grace of God and the merit of Christ alone, as explained in the preceding article. 23] Again, they [these propositions concerning the necessity of good works for salvation] take from afflicted, troubled consciences the comfort of the Gospel, give occasion for doubt, are in many ways dangerous, strengthen presumption in one’s own righteousness and confidence in one’s own works; besides, they are accepted by the Papists, and in their interest adduced against the pure doctrine of the alone-saving faith. 24] Moreover, they are contrary to the form of sound words, as it is written that blessedness is only of the man unto whom God imputeth righteousness without works, Rom. 4:6. Likewise, in the Sixth Article of the Augsburg Confession it is written that we are saved without works, by faith alone. Thus Dr. Luther, too, has rejected and condemned these propositions… 29] Accordingly, and for the reasons now enumerated, it is justly to remain settled in our churches, namely, that the aforesaid modes of speech should not be taught, defended, or excused, but be thrown out of our churches and repudiated as false and incorrect http://bookofconcord.org/sd-goodworks.php

(Note that the Formula fully affirms the third use of the law).