The issue is that after the emergence of L2s nobody wants to pay L1 fees while they can get the same equivalent service on L2s
It depends on the implementation of L2s. Because there are many possible options. For example, if by mining some sidechain, you can get real BTCs directly, then your actions would eventually lead to some on-chain transaction anyway.
Because if L1 is expensive, and L2 is cheap, then it is not a problem, if all L2 transactions are batched, and pushed into L1. Because then, thousands of users paying small fees, could be batched into a single on-chain high-fee transaction, covering everything, what they did on the second layer.
because there's no smart contract functionality
It is possible to use smart contracts on second layers, even if they are not implemented on-chain. The only thing that matters, is the translation of all of that into a proper on-chain transaction later. And the simplest way to do that, is to just require a given amount of Proof of Work. Then, the on-chain version can only check, if there is enough Proof of Work, and everything else can be done by the second layer.
mining won't be gone
Yes, since we now have Proof of Work inside scripts, it can be deployed everywhere. Even in regtest, where mining is extremely easy, it is possible to create coins, which would require a lot of Proof of Work to be moved.
What if L2s and sidechains make on-chain transactions impractical and therefore affects the fee market adversely?
Then, users will stay on second layers, and a single on-chain transaction would be used to handle a lot of users. Because then, if you have on-chain fee of 1000 sat/vB, then you can have thousands of users, paying 1 sat/vB each. And if from the on-chain perspective, the only checked thing would be "this transaction has X amount of Proof of Work", then it would be quite small, no matter how many users will be attached to the second layer.
+----------------------------------------------------------+
| sidechainX_stateA 1.00 BTC -> sidechainX_stateB 0.99 BTC |
+----------------------------------------------------------+
Something like that could take around a kilobyte on-chain. Which means 1000 sat/vB. And then, it doesn't matter, if you have thousands, or millions of users in the sidechain, because it is all about replacing one 256-bit number with another 256-bit number, from the on-chain perspective. And a single 256-bit hash can commit to the whole UTXO database from some sidechain, or another second layer.
Wouldn't that have a bad effect on bitcoin's longevity especially as block rewards diminish?
I think on-chain fees could be too high, instead of being too low. Because there are many non-monetary use cases, where users use 99% fees in practice. And then, if fees around halvings can spike, and
you can have 40 BTCs in the coinbase transaction, then I wouldn't worry about the amount. I would worry more about distributing it roughly equally over time, because when you have one block paying around 40 BTC, and another block paying around 8 BTC, then there may be some incentive, to reorg a previous block, instead of mining a new one on top of it.
Couldn't bitcoin face a crisis over who's going to protect the network due to the lack of incentives down the line?
Well, people are still mining testnet3, even though there were 23 halvings, and there are only 596 satoshis in the basic block reward, and everything else comes from fees. So, I wouldn't worry too much about it.