This is the phrase known as the Golden Rule.
“The content of this saying has parallels in a broad spectrum of ancient literature in the Greek, Roman, Jewish, and Oriental world. One of the most commonly cited parallels comes from the Talmud where Hillel, who lived just before Jesus, answered a query about the law’s content with “What is hateful to you, do not do to your fellow-creature. That is the whole Law; all else is explanation. Numerous other parallels exist in late Jewish literature. Although some have attribute the positive formulation to Jesus and the negative to common sense and therefore distinguished between the basic thrust of the two formulations, the positive expression also appears… Furthermore, the early church preserve the saying in its negative form in Didache 1:2 and acts 15:20, 28. In other words, it would be difficult to demonstrate that the content of the Golden Rule in itself was unique to Jesus or the early church.” (Robert Guelich. A Foundation for Understanding the Sermon on the Mount. Word Publishing, Dallas. 1982, p. 360-361).
This saying continues the emphasis on the horizontal relationships, and is perhaps best paired with first five verses that similarly deal with interpersonal relationships. A difference, however, is that there is not an essential antithetical relationship between the clauses. This further suggests that this is a common saying that is inserted in the Sermon rather than one that follows the format of the other sayings in the Sermon.
Textual: There are no changes from the Matthean text.