How many graduate-level courses should one take to maximize chances of getting into graduate school? (PhD)
Graduate-level courses are helpful, but there isn't any magic formula that "X courses with a grade of A or A- will guarantee admission." Every case is different, and good grades are by no means sufficient for admission, if your letters of recommendation are weak. 

If you're applying for a terminal master's program that is primarily coursework, then the rules are different, but for anything relying on research, your research experience and letters of recommendation will carry significant more weight than your classwork and test scores. What doing well in the graduate courses does is signify that you will be able to handle the coursework in your program, but it does not shed light on the rest of your abilities.

So my recommendation is to take graduate classes because you're interested in the subject and want to learn more about it, rather than just to impress an admissions committee.