This particular question has been discussed numerous times here, I will actually advise that you use more of the search button for questions like this.
Nonetheless, this is actually a worry that I think all of us here wouldn’t be alive to see the last bitcoin mined and just like quantum computing scares let’s leave the worries till then.
We talk about bitcoin 21m cap everyday but I think we talk less about what happen after year 2140. The block subsidy is scheduled to reach zero around the year 2140. After this, there will be no more new coins and miners will survive only on transaction fees. This was part of Satoshi original design but I'm curious whether this is sustainable in practice. Will that be enough to secure the network?
I think in the next 20 years to come we will be even getting it clearer as maybe transaction fee will actually be sufficient for miners because by the 10th halving around 2048 the block reward would have reduce to 0.0488 bitcoin per block which is quite lower than even what miners earn now from bitcoin fees and further years more miners will be depending on fees far away from the exact year that the mining will be completed so it will be clear what happens next before 2140.
The idea is that the increasing price of bitcoin will help cushion for this plus then bitcoin would have had more adopters which means more transactions. Even if the block size remains same and then the people prioritize the layer 2s like lightening network, then opening/closing of channels will be on the base network plus it means larger transactions will be on the network too.
So by then technically we should be seeing more bitcoin been accumulated as fees and with the increase in the price then it could just be enough.