Matthew begins his gospel with a genealogy of Jesus, right before then introducing the birth narrative. Luke, however, waits until after the story is somewhat underway before presenting his genealogy of Jesus. What is Luke's purpose in giving the genealogy after Jesus' baptism by John rather than as part of his birth narrative?
4 Answers
The reason Luke provides the genealogy of Jesus after Jesus' baptism, at which time the Father calls Jesus "My beloved son" (Luke 3:22), is because those very words from the Father are the basis for Luke's later assertion that Jesus is "the son of God" (Luke 3:38).
In his commentary on Luke 3:23, John Lightfoot wrote,
Joseph is not here called the son of Heli, but Jesus is so: for the word Jesus must be understood, and must be always added in the reader's mind to every race in this genealogy, after this manner: "Jesus (as was supposed) the son of Joseph, and so the son of Heli, and of Matthat, yea and, at length, the son of Adam, and the Son of God." For it was very little the business of the evangelist either to draw Joseph's pedigree from Adam, or, indeed, to shew that Adam was the son of God: which not only sounds something harshly, but in this place very enormously, I may almost add, blasphemously too.
For when St. Luke, verse 22, had made a voice from heaven, declaring that Jesus was the Son of God, do we think the same evangelist would, in the same breath, pronounce Adam 'the son of God' too? So that this very thing teacheth us what the evangelist propounded to himself in the framing of this genealogy; which was to shew that this Jesus, who had newly received that great testimony from heaven, "This is my Son," was the very same that had been promised to Adam by the seed of the woman. And for this reason hath he drawn his pedigree on the mother's side, who was the daughter of Heli, and this too as high as Adam, to whom this Jesus was promised.
In the close of the genealogy, he teacheth in what sense the former part of it should be taken; viz. that Jesus, not Joseph, should be called the son of Heli, and consequently, that the same Jesus, not Adam, should be called the Son of God. Indeed, in every link of this chain this still should be understood, "Jesus the son of Matthat, Jesus the son of Levi, Jesus the son of Melchi"; and so of the rest...
References
Lightfoot, John. A Commentary of the New Testament from the Talmud and Hebraica.
One explanation that some scholars (though not a majority) think explains this, is that there was an earlier version of Luke which began at verse 3:1 (or which skipped straight from the preface 1:1-1:4 to 3:1). The evidence is somewhat circumstantial, but Luke 3:1 looks like a beginning and there's some differences in language and themes between the first two chapters and the rest. Finally, it's known that Marcion's gospel looked a lot like Luke and definitely started at 3:1. The location of the genealogy is much less weird if it was in its current location before a birth narrative was added. This argument is briefly sketched in this blog post of Bart Ehrman's, though the idea is not his originally.
To combine the answers above, Luke positions the genealogy of Jesus between his baptism and the temptation to build on several themes: 1. Jesus as the Son of God, and 2. Jesus as the fulfillment of Adam's sonship, 3. Jesus as the fulfillment of Israel sonship.
It might be helpful if visually we can see how Luke has arranged the text:
When all the people were being baptized, Jesus was baptized too. And as he was praying, heaven was opened and the Holy Spirit descended on him in bodily form like a dove. And a voice came from heaven: "You are my Son, whom I love; with you I am well pleased."
Now Jesus himself was about thirty years old when he began his ministry. He was the son, so it was thought, of Joseph, the son of Heli, [...] the son of Seth, the son of Adam, the son of God.
Jesus, full of the Holy Spirit, left the Jordan and was led by the Spirit into the wilderness, where for forty days he was tempted by the devil. He ate nothing during those days, and at the end of them he was hungry.
The devil said to him, "If you are the Son of God, tell this stone to become bread."
First Luke begins with God's own testimony that Jesus is his Son. Next, Luke organizes his genealogy in order of son to father instead of father to son in order to be able to end with the statement of Jesus again being "son of God." Finally, by placing "the son of Adam, the son of God" back to back with the temptation narrative, Luke links for his readers the temptation of Jesus with the temptation of Adam. Jesus thus shows himself to be not only the son of God, like Adam, but also the true Son of God who is able to resist temptation.
This furthermore plays off of the idea of the wilderness temptation of Israel, also called God's son. Thus by placing the genealogy here, Luke is able to show Jesus as not only fulfilling the role of Israel as God's son, but also the role of Adam and humanity.
See my answer to Jesus as Adam in the Gospels?
Luke presents Jesus as a new Adam.
This is beyond a doubt Luke’s purpose in the placement and arrangement of Jesus’ genealogy. Unlike Matthew who places his genealogy at the outset of his gospel, Luke places it immedietly after Jesus’ adult baptism and immediately prior to his three temptations. The genealogy is thus bookend by the issue of Jesus’ sonship. In the baptism God declares Jesus to be His “beloved Son” and in the temptations Satan challenges Jesus, “if you are the Son of God…”
Also instead of beginning with Abraham and working forward to Jesus, as Matthew does in the genealogy he records (Matthew 1:1-16), Luke genealogy begins with Jesus and works backwards to Adam (Luke 3:23-38). The net effect makes his genealogy a list of sons rather than a list of father and points to Adam as also God's son. Luke is making an implicit comparison between these two men. Only Jesus and Adam are said to be God's son.