Why would a professor (say in pure math) want to take PhD students? Why would a professor doing pure math/ theoretical computer science want to take PhD students?

I understand that in computational and experimental sciences taking students is at least beneficial to them. However, in subjects like pure math, it is not obvious to me that there are any significant advantages to take some PhD students. It is probably expected from the department that you will take some students, and it is nice to have someone who can type things up for you. But other than that, I don't see any reasons.

So, why would they want to do that? What are they expecting from their (prospective) students?
They get to train the next generation of mathematicians. They get to establish a relationship with young students, guide new researchers when they are up-and-coming and those people become their students. For the rest of time those researchers will be the person trained by Professor Stella and that is intrinsically valuable for several reasons:


Some people like teaching. I love teaching, and if I leave industry and go into university research it will be largely because I want to teach. The ability to work with and mould young minds really appeals to me, and I get value out of knowing that I've helped people learn.
You develop an attachment, and a sense of pride, in your students. Their accomplishments become, not quite yours, but close to feeling like yours. If you’ve ever served as a TA, you’ve probably worked for a long period of time with a struggling student. Maybe you felt a twinge of pride when they finally got it, or got a good grade on an exam. When you’re an advisor, you get a lot more than a twinge.
They are part of your legacy. They will tell stories about being your student for another 20+ years after you pass away, they will toast you at banquets in their honor and thank you for making them the researcher that they are today. 


What a professor expects of you is that you try your very best to be a good scientist, that you do interesting work, and that you continue to carry on the torch of mathematics for another generation after they are gone.