How necessary it is to have PhD students?
It certainly depends on the department you're in. Some departments have small PhD programs and largely focused on undergraduate and master's programs. In that case, you may get away with just not having PhD students. On the other hand, at most Research-1 universities, math departments have 1.5-2 PhD students per tenure-track faculty. Of course, faculty do not evenly assume mentorship roles for them, but there is an expectation that one does, in fact, supervise some. It is not uncommon to have an expectation that, for example, one has to have graduated one PhD student before promotion to full professor.

In general, the way to see this most productively is probably to remember that a university is an institution of higher education. If a department has a PhD program as an important component, then it is a reasonably expectation that every tenure-track faculty participates in it by (i) teaching graduate courses, and (ii) advising PhD students. If you actively try to get out of one or both of these parts of your job, you're not doing your job. The situation is no different than teaching and service: it's part of your job, and whether you do or do not like this part makes no difference in the expectations that are put on you.