I've heard it said that the point of a Ph.D. is less about the specific thesis topic than the fact that you can spend 8 years going deep on some arbitrary thing and come out successful. If someone needs a problem solved that takes 8 years of focus to do, a Ph.D. is a pretty good indicator that you can do it reliably. If you're the sort of person who enjoys taking (up to) 8 years to make a contribution to the world, a Ph.D. is a good way to do it, and also to prove to others you can do it.
Most of my college professors, I believe, had thesis topics that are only loosely related to their current field of research. To pick a random example, Ron Rivest's thesis was on searching large files or something, which is somewhat related to one of his most famous publications (the algorithms textbook), completely unrelated to the other (the RSA algorithm), and mostly, I think, unrelated to his current research (secure electronic voting).
I disagree that is the point of a PhD is some kind of struggle to get through, I honestly enjoyed mine and don't think the topics are so interchangeable.
Research topics drift over time, but the starting point is still significant.
So you have letters after your name and people take you seriously and no-one can say you wasted your life exhuming lifeless ideas and padding them out into a massive document that no-one will ever read. Or something.
Generalist and specialist are not mutually exclusive. Someone can simultaneously have some knowledge of many different areas, and deep knowledge of one particular area. This is in contrast to someone who has no deep knowledge in any area ("knows something about everything") or someone who only has extremely deep knowledge of only one area ("knows everything about nothing").