The reason is that there used to be violent rebel factions in Perú, the most dangerous known being "Shining Path". Their primary leader was arrested. Then their second in command. The group still exists but is much less prominent now deprived of their leaders, they have gone quiet over the past decade or so. The police and military are there to protect the people with the full support and gratitude from the people. They are both highly regarded by Peruvians as the saviours and protectors. They also serve to protect the tourists and travelers, who represent the primary source of revenue for Perú, from such violent rebel groups.