Gibbs, Jeffrey A. “Matthew 5:38-42: On Revenge." Matthew 1:1-11:1. St. Louis: Concordia Publishing House, 2006, pp. 297-300.
In Matthew 5:38, Gibbs notes that the use of the preposition ἀντί with the genitive is shown to regularly mean "in exchange for." The quotation Jesus makes is from Exodus 21:24, Leviticus 24:20, and Deuteronomy 19:21, word for word, except for the added "and." (Gibbs 2006, 301).
Verse 39 is somewhat more complex. Gibbs notes that some have attempted to make the dative "evil" a dative of means, thus allowing, "not to resist by evil means." However, Gibbs finds the use of the verb typically includes a direct object in the ddative case, no less than 47 times in the Septuagint and the New Testament. Therefore, Gibbs considers "evil" to be the direct object here (Gibbs 2006, 301).
Gibbs observes that Jesus' teaching in Matthew 5:38-42 is about "the true divine intent of the Torah" (Gibbs 2006, 302). Rather than keeping track of instances of evil so as to gain retribution, we do good. Gibbs cites Kleinig's commetary on Leviticus showing that the Israelite law of retribution was particularly intended to put limits on retribution. Jesus' teaching is that we self-limit the use of retaliation. Gibbs illustrates this by the life and sacrifice of Jesus (Gibbs 2006, 303).