[Matthew 10:39] Whoever finds his life will lose it, and whoever loses his life for my sake will find it.
The latter part of the verse will help us understand the former part. If you have lost your life, that is, died, the only way you can subsequently find your life, that is, keep it/preserve it, is if you are brought back from the dead, i.e. resurrected. Are believers in Christ promised a resurrection? Yes.
[Romans 6:5] For if we have been united with him in a death like his, we shall certainly be united with him in a resurrection like his.
When does the resurrection happen? In the next age, at the start of the millennium.
[Revelation 20:4-6] Then I saw thrones, and seated on them were those to whom the authority to judge was committed. Also I saw the souls of those who had been beheaded for the testimony of Jesus and for the word of God, and those who had not worshiped the beast or its image and had not received its mark on their foreheads or their hands. They came to life and reigned with Christ for a thousand years. 5 The rest of the dead did not come to life until the thousand years were ended. This is the first resurrection. 6 Blessed and holy is the one who shares in the first resurrection! Over such the second death has no power, but they will be priests of God and of Christ, and they will reign with him for a thousand years.
Incidentally, this verse tells us that unbelievers ("the rest of the dead") will also be resurrected, except after the millennium. Taking all this together, we can understand Matthew 10:39.
In the latter part of v.39, Jesus is telling us that if we lose our life for His sake in this age, that is only temporary, and we will ultimately find it, that is, keep it/preserve it in the next age. However, if we find (that is, preserve/keep) our life in this age at the expense of being a follower of Christ (the context of v.39, which is about following Christ and "taking up your cross", helps us determine this), and at the expense of the gospel (see Mark 8:35), that is only temporary, and we will ultimately lose it in the next age, that is, we will physically die. There is evidently a symmetry between the first half of v.39 ("whoever finds his life will lose it") and the second half of v.39 ("whoever loses his life for my sake will find it"). In both halves of v.39, Jesus begins by speaking about this current age and then switches to the next age.
1: whoever finds his life [in this age] will lose it [in the next];
2: whoever loses his life [in this age] for my sake will find it [in the next].
This interpretation agrees with the context of v.39. Throughout Matthew 10, Jesus has spoken of the persecution His followers will endure (see esp. v.16-18, v.21-23, v.34-36). However, Jesus does not simply leave them like that. He gives them a rationale for choosing to believe in Him and be His followers even in the face of harsh adversity; "ultimately everything will come to light, and everyone will be judged, including you; if you remain faithful to me and endure through persecution, you will be judged favourably and will be saved; however, always remember the One who truly has the power to condemn, and how men are greatly limited in comparison."
[Matthew 10:21-22] Brother will deliver brother over to death, and the father his child, and children will rise against parents and have them put to death, 22 and you will be hated by all for my name's sake. But the one who endures to the end will be saved.
[Matthew 10:26-28] So have no fear of them, for nothing is covered that will not be revealed, or hidden that will not be known. 27 What I tell you in the dark, say in the light, and what you hear whispered, proclaim on the housetops. 28 And do not fear those who kill the body but cannot kill the soul. Rather fear him who can destroy both soul and body in Gehenna.
[Matthew 10:31-33] Fear not, therefore; you are of more value than many sparrows. 32 So everyone who acknowledges me before men, I also will acknowledge before my Father who is in heaven, 33 but whoever denies me before men, I also will deny before my Father who is in heaven.
Jesus has given us an assurance: if we endure through persecution for the sake of His name, He will acknowledge us before His Father in heaven and we will be saved (v.22 and v.32). But He has also given us a warning: if we deny Christ before men, He will deny us before His Father in Heaven, who has the capacity to "destroy both soul and body in Gehenna" (v.28 and v.33). So, that's an assurance and a warning. Now we get to one of the most extreme parts of the chapter.
[Matthew 10:34-39] Do not think that I have come to bring peace to the earth. I have not come to bring peace, but a sword. 35 For I have come to set a man against his father, and a daughter against her mother, and a daughter-in-law against her mother-in-law. 36 And a person's enemies will be those of his own household. 37 Whoever loves father or mother more than me is not worthy of me, and whoever loves son or daughter more than me is not worthy of me. 38 And whoever does not take his cross and follow me is not worthy of me. 39 Whoever finds his life will lose it, and whoever loses his life for my sake will find it.
As you can see, the immediate context of v.39 is incredibly intense. Throughout v.34-38, Jesus cautions us. Being a follower of His could mean having to give up our father or mother or son or daughter! And He has warned us that if we are not willing to do all of this, we are not worthy of Him!! And He also tells us that if we do not "take up our cross" and follow Him, we are not worthy of Him. Taking up our cross is an allusion to Jesus' death on the cross, which means that Jesus is telling us that we need to be willing to die if we are to be worthy of Him. He concludes this intense injunction with both a warning and an assurance; "Whoever finds his life will lose it, and whoever loses his life for my sake will find it". The first half of v.39 is the warning, while the second half of v.39 is the assurance.
Warning: If we preserve our life temporarily in this age at the expense of being a follower of Christ, we will ultimately lose our life in the coming age.
Assurance: If we lose our life temporarily in this age for Christ's sake, we will ultimately preserve our life in the coming age.
However, what if Jesus is not talking about losing our life in the coming age in the first half of v.39, but about losing it in this current age? Well, then, Jesus' words are no longer a warning. Not only that, but it breaks the symmetry I pointed out earlier (as the second half of v.39 is unarguably and incontrovertibly about preserving your life in the next age [again, the only way someone can lose their life and subsequently preserve it is if they are resurrected, and the resurrection of the righteous happens at the coming of Jesus, at the start of the next age]). Worst of all, it makes Jesus' words trivial and insignificant. This would be in complete disharmony with both the immediate context and larger context, as seen by the foregoing.
If Jesus is telling His disciples that they will lose their life in this age if they seek to preserve it, His words have no significance to them or anyone else, since everyone will die in this age no matter what, regardless of whether one preserves their life at the expense of Christ and the gospel! Half of the verse becomes totally inconsequential and even redundant (again, each and every one of Jesus' disciples will die [and have died] no matter what, regardless of anything they do. So there was absolutely no point in Jesus telling His disciples this). Now, does Jesus ever speak such unimportant words, as the words found in the first half of v.39 would be under this interpretation? Perhaps. But does He ever speak them in a context like the one v.39 is found in (a context that is decidedly not unimportant in any manner whatsoever)? I'd say that's inconceivable. Even worse, are such unimportant words ever misleadingly recorded in scripture numerous times throughout all four gospels, as though they are significant when in reality they are not (in addition to Matthew 10:39, see Matthew 16:25, Mark 8:35, Luke 9:24, Luke 17:33, and John 12:25)? As you can see, the interpretation that Jesus is talking about losing your life in this age in the first half of v.39 is completely untenable, and it is orders of magnitude more reasonable to conclude that Jesus is speaking about ultimately losing your life, that is, dying in the next age.
Ok, well what if the "it" in the first half of Matthew 10:39 is referring to something different from "life" [ψυχή], say for example, "eternal life" (as it is interpreted by @Dottard) or "spiritual life". Is that grammatically permissible? No. Matthew 10:39 in Greek is:
ὁ εὑρὼν τὴν ψυχὴν (noun - accusative case - feminine singular) αὐτοῦ ἀπολέσει αὐτήν (possessive pronoun - accusative case - 3rd-person feminine singular); καὶ ὁ ἀπολέσας τὴν ψυχὴν αὐτοῦ ἕνεκεν ἐμοῦ εὑρήσει αὐτήν.
αὐτήν (autēn) is a possessive pronoun, it's in the accusative case (meaning it's the direct object of the verb ἀπολέσει), and 3rd-person feminine singular. ψυχὴν (psychēn) is a noun, also in the accusative case, and feminine singular. Both αὐτήν and ψυχὴν are feminine singular, meaning ψυχὴν is the antecedent of αὐτήν, that is, ψυχὴν is the referent of αὐτήν. This is reflected in every English Bible translation on the face of the earth. "It" (αὐτήν) is not referring to something separate from "life" (ψυχὴν) but is referring back to "life" (ψυχὴν), because "life" (ψυχὴν) is the antecedent, and consequently the referent, of "it" (αὐτήν). This is true in both the original Greek and English translations. Every single English translation I've looked at translates the Greek of Matthew 10:39 in essentially the same way. Just some examples:
(NASB) The one who has found his life will lose it, and the one who has lost his life on My account will find it.
(ESV) Whoever finds his life will lose it, and whoever loses his life for my sake will find it.
(BSB) Whoever finds his life will lose it, and whoever loses his life for My sake will find it.
(NIV) Whoever finds their life will lose it, and whoever loses their life for my sake will find it.
(NKJV) He who finds his life will lose it, and he who loses his life for My sake will find it.
(ASV) He that findeth his life shall lose it; and he that loseth his life for my sake shall find it.
(BLB) The one having found his life will lose it, and the one having lost his life on account of Me will find it.
(LSV) He who found his life will lose it, and he who lost his life for My sake will find it.
(YLT) 'He who found his life shall lose it, and he who lost his life for my sake shall find it.
I could not find a single translation (I checked both Biblehub and Biblegateway) that renders αὐτήν ("it") as though it's a separate reference to ψυχή ("life"), e.g. "Whoever finds his life will lose his life, and whoever loses his life for my sake will find his life." Matthew 10:39 is unambiguous, straightforward, and incredibly easy to translate (again, this is reflected in every single English Bible translation in the world). The possessive pronoun αὐτήν works the same way in Matthew 10:39 as the possessive pronoun "it" works in English, not differently. Meaning αὐτήν refers back to the "life" (ψυχὴν) Jesus had just mentioned, not to some separate, indefinite, unspecified ψυχὴν that can mean something entirely different from the ψυχὴν Jesus had just mentioned half a second ago, e.g. "spiritual life" or "eternal life". I'll reiterate. The relationship between the pronoun (αὐτήν) and the antecedent (ψυχὴν) in Matthew 10:39 works the same way as it does in English; Jesus, with His usage of αὐτήν, is referring back to the ψυχὴν He had just mentioned half a second ago ("ψυχὴν" is the explicit referent of "αὐτήν"), not to some indeterminate ψυχὴν that can have some meaning that's entirely distinct from the meaning of the ψυχὴν He had just used! So, if the original "ψυχὴν" refers to physical life, then "αὐτήν" (which is the pronoun being used to refer to its antecedent, NOT to some undefined ψυχὴν) also refers to physical life. It cannot refer to "eternal life" or "spiritual life", unless, of course, the antecedent "ψυχὴν" also refers to "eternal life" or "spiritual life" (in which case Jesus would be telling us that if we preserve our eternal life or spiritual life we will lose them eventually, which doesn't make any sense). So the interpretation proffered in the answer by @Dottard isn't grammatically permissible.1
In conclusion, Matthew 10:39 teaches us that those who choose to give up their life for the sake of Christ and the gospel, though they temporarily die in this age, will ultimately preserve their life in the coming age and live forever. While those who choose to keep their life at the expense of being a follower of Jesus, and at the expense of the gospel, though they temporarily live in this age, will ultimately lose their life in the coming age and die.
Hope this helps! Have a good day. :)
1 It is worthy to note that whenever Jesus referenced eternal life, He always used the Greek word ζωή (zóé), and never ψυχή (psuché). Perhaps the greatest example of this is John 12:25, where Jesus uses both ψυχή and ζωή and plainly differentiates between eternal life and physical life (I'm not saying that eternal life is not physical life; it is, namely, physical life that lasts for eternity. I'm saying that when Jesus employs ψυχή, He does so to denote physical life without reference to duration, whether limited in duration [mortal life] or unlimited in duration [eternal life]. There are many definite examples where Jesus uses ψυχή in such a manner, e.g. Matthew 6:25; 10:39; 20:28; Mark 3:4; 10:45; Luke 6:9; 9:24; 12:22-23; 14:26; 17:33; John 10:11; 15; 17; 12:25; 13:37-38; 15:13). In the first half of John 12:25, Jesus uses ψυχή to refer to physical life, and, instead of continuing to use ψυχή to refer to eternal life in the second half, He switches to ζωή and uses that to refer to "eternal life" (αἰώνιον ζωὴν) instead. Had Jesus had eternal life in mind in Matthew 10:39, He would have used ζωή, not ψυχή.