Hi OP
3 years ago.I could have written your post. Dh and I have been together for 24 years, and have dc aged 21 and 19. Our sex life dwindled after the birth of the dc until sex only happened a few times a year - maybe 5 or 6 at best. One year it was 3 times.
About once a year dh and I would have a long discussion about it which always ended in a blazing row. Dh could never really explain why his sex drive had dropped so low. I felt very unloved and rejected. He would promise to try to improve things but nothing ever changed.
However, apart from the lack of sex, our marriage was great in every other way I loved dh, he loved me, we had good fun together, parented our dc together. About 6 years ago I decided I had to make a decision - either leave dh because I couldn't bear the idea of going through the rest of my life with little/no sex, or accept the situation and try not to resent it, but live in a sexess marriage that was otherwise good. I chose the latter. My stipulation to dh and to myself was that sex would be completely off the agenda. One of the very hard things to come to terms with was the sporadic sex, because every time it happened, I would be hopeful that it was the start of a more regular sex life but it never was. Taking sex out of the equation completely helped me a lot.
And then about 2 -3 years ago, things changed again. We went away for a weekend and ended up having sex. I was very upset as I didn't want to get back into the cycle of occasional sex followed by weeks of being rejected. However, when we got back home the sex continued. We now have a reasonably active sex life - probably about 6-8 times per month which is fine. We both work full time and do a lot of sport so that feels right for us and it's much better than it was.
Dh cannot explain why his sex drive was so low for so long, nor why it seems to hsve come back. He is now 55 and seems to habe no problem getting/maintaining an erection. I am as certain as I can be that no other woman was involved. He only got his own smartphone this year - previously the only phone he had was his work phone and he absolutely would never have used that to access pornography so I'm certain that wasn't the issue. He had a vasectomy after the dc were born so no fear of another pregnancy.
The one thing I have noticed is that our sex life dwindled conpletely as the dc got older. When they were little they were really good sleepers and never woke in the night. However, as they got older they stayed up later and dh never wanted to have sex when they were awake. He never cited this as a reason but I think the two are connected. In the last couple of years, the dc have been out much more in the evebings so we have the house to ourselves. Also, being teenagers they have slept in really heavily in the mornings and dh definitely prefers sex in the mornings.
So, I don't know what my advice to you really is. I made the decision to live in a sexless marriage which I found very sad, but ultimately wanted dh/my marriage more than I wanted sex. However, I wouldn't say that was right for everyone, just for us. It did get much easier once I made the decision that sex was completely off the agenda. And then of course things finally came good for us. But I didn't anticipate that when I made the decision to stay in my marriage.
If you don't feel that you can live for the next 40 years without sex, then don't stay. I am still quite resentful at times about the fact that I lived for years with almost no sex, but then remind myself that it was ultimately my choice to stay in my marriage. Now that the dc are grown up, I do wonder if I would have continued to stay if our sex life hadn't improved.