You probably cannot change him. You can say, "I don't understand. Explain it to me." And watch him struggle. You can probe further: "So, you are saying that brown people are stupid? That they are lazy?" Let Grandpa go on...he probably will fizzle out.
I grew up with a father who told Polish, Italian, Irish, anti-woman (et cetera) jokes and justified them because he heard them from the Poles, Italians, Irish and women in his life or at his job. I struggled mightily in the formative years of the women's movement to tell him that jokes about blondes or women drivers were not acceptable (same for other groups). He was offended. But he slowed down.
So, set a goal. Do you want to A) change his mind? Or do you just want to B) change his behavior in public? Or do you just want to C) avoid situations in which he has a prompt to say things? The strategy varies based on your objectives. So, A) ask the "What do you mean/explain it" question. B) Tell him you're going into a diner with people of color (which is the preferred term - not sure why some would object) and if he grouses, you're leaving. C) Go elsewhere and tell him you aren't going to the diner because he's so offensive to Peruvians. He can think what he wants, but you aren't going to participate.
Also, be careful of your own terms. You say "Lima women" so be sure you can explain to your grandfather how you know that these women are from Lima vs. other places in Peru. You'll educate him by showing you talked to them to find out where they are from, rather than assuming they are from Lima. Otherwise, don't use terms like "Lima women" that can be misconstrued by people like your grandfather and pretty much everyone else.
If it were me, I'd apologize to the workers for your elderly grandfather who grew up in an isolated environment, and I'd give them an extra tip (in their hands, not just on the bill to be divided among everyone). Military Mom has a great response below on that subject. I'd tell Grandpa we aren't going there again, although I'd say I'll be going back on my own to give my hard-earned dollars to the hard-working people. Then I'd change the subject to something he likes: "How about those Yankees?" "What do you think of the Giants' chances?" "Want to take in a Phillies game?" "Hey, the museum has Free Friday admissions. Want to go?"
Also, a lot depends on whether he is 60 or 90. The potential for change is less at 90 so just enjoy the years you have left.