There is a lot that goes into answering this question.

I usually give an hour-long lecture on the role of pH in HPLC during my hands-on HPLC courses.

So first let me give you a big picture view and then dive into the most important details.