I did a PhD (not in CS) because I wanted to understand a set of scientific problems in depth, do the research, understand setting up experiments, monitoring them, etc. There are other ways, but it takes 2-3 years of semi-structured work to wrap your head around some of these aspects. At the same time, it helps to understand what you like/don't like and try out new methodologies and areas of research.
Not the only way to get there, but a very fun one.
Not the only way to get there, but a very fun one.