In the Gospel of Mark, the author gave the Roman centurion the last word at the crucifixion:
“Now when the centurion, who stood facing him, saw that in this way he breathed his last, he said, “Truly this man was God’s Son!” (Mk 15:39 NRSV)
I suggest that Matthew wanted to avoid the ambiguity of Mark’s scene. Matthew added a new scene that stars the centurion (Mt 8:5-13). It paints the centurion as a man of faith:
5 When [Jesus] entered Capernaum, a centurion came to him, appealing to him 6 and saying, “Lord, my servant is lying at home paralyzed, in terrible distress.” 7 And he said to him, “I will come and cure him.” 8 The centurion answered, “Lord, I am not worthy to have you come under my roof; but only speak the word, and my servant will be healed. 9 For I also am a man under authority, with soldiers under me; and I say to one, ‘Go,’ and he goes, and to another, ‘Come,’ and he comes, and to my slave, ‘Do this,’ and the slave does it.”
10 When Jesus heard him, he was amazed and said to those who followed him, “Truly I tell you, in no one in Israel have I found such faith. 11 I tell you, many will come from east and west and will eat with Abraham and Isaac and Jacob in the kingdom of heaven, 12 while the heirs of the kingdom will be thrown into the outer darkness, where there will be weeping and gnashing of teeth.” 13 And to the centurion Jesus said, “Go; let it be done for you according to your faith.” And the servant was healed in that hour. (NRSV)
The superficial purpose of this scene in the Gospel of Matthew is to show that the centurion has great faith. But Jesus has already praised several people for having faith, and, arguably, their faith enabled them to be healed. The centurion scene seems repetitive. Why did Matthew add this scene?
Let us assume that Matthew is not making fun of the centurion for having excessive or unrealistic faith. And let us assume that Matthew is not making a point that a Gentile has faith.
Matthew must have known that the Gospel of Mark had been a performed play. (Only about 50 years had passed.) In the performed play, the centurion’s statement “Truly this man was God’s Son!” (Mk 15:39) had created a complex dramatic experience for the audience. They had earlier seen the centurion as one of the Satanic-spirit-possessed pigs (Roman soldiers). In the Gospel Mark, the centurion’s statement, like the other statements by Satanic spirits (e.g., Mk 3:11) though true, was Satanic! And was the centurion being sincere, or contemptuous?
Matthew must have expected his readers/hearers to wonder why a Roman soldier recognizes Jesus as the Son of God earlier than his disciples and other Judeans/Galileans.
Matthew knew that his readers/hearers did not have a memory of the performance. He could not assume that they would infer that the centurion was possessed. Therefore, I propose Matthew added the centurion/faith scene (Mt 8:5-13). The centurion’s statement in Mk 15:39 was now (only) a statement of faith.