I got lucky with a great supervisor and I learned a lot when I did my PhD. Not everybody is that lucky and there are a lot of obstacles to completing a PhD. But most of those are on you. It's supposed to be hard. Not easy. Motivation for doing the work is a function of how inspiring the work is, how much you can accomplish with your own mind, and how well you are supported. The latter is a function of how coacheable you are and how good your supervisor is. Sometimes the best researchers are also the worst on that front. And of course not everybody is that good at mentoring others.
If any of that does not add up, you are in going to have to do something. In a way, a PhD. degree is the reward for your ability to overcome such obstacles. It's a lonely job and with few exceptions, the only readership for your hard work is the handful of people who will actually read more than a few pages of your thesis and only because they have to. And yet you have to take it seriously and get it done. You might feel like you are wasting years of your life. But think of the person indulging you for all those years and trying to do their best to nudge you in the right direction.
My advice would be to only do a PhD for the right reasons (i.e. the knowledge and the learning instead of the degree) and only if you can find the right mentor to coach you through it. Your first failing might be rooted in getting either of that wrong.