In August of 2007, a magnitude 8 earthquake struck the central coast of Peru, killing 519 people and injuring nearly 1,500. Tens of thousands of homes were destroyed, and a tsunami up to 5 meters high flooded the Pisco shore and the Costa Verde Highway.
On May 26th, 2019, a magnitude 8 earthquake struck Peru just east of the Andes. Falling debris killed two people, and at least 30 more were injured. Many old houses collapsed, a bridge or few fell, and some roads were blocked, but the damage was far less severe than in 2007.
Both quakes were caused by the Nazca plate subducting beneath the South American plate. It's moving east at roughly 70mm per year in this area. So why would one quake case hundreds of deaths and catastrophic damage to a large area, and another quake of the same magnitude on the same plate cause so little?
Zooming out, we see a plate boundary extending 7000 kilometers, pushing up the Andes, giving birth to volcanoes, and causing frequent huge earthquakes. But not all of those earthquakes happen at the same distance from the trench or at the same depth. And that matters a lot when it comes to how devastating a large-magnitude quake will be.
Earthquakes in the Nazca plate happen up to 650km deep, though most of the large ones occur in the upper 70km, where the crust of the South American plate is actively being deformed by the collision and the two plates slide past each other. The 2007 Pisco, Peru earthquake was one of these, occurring at a depth of only 39km. These are the familiar and dreaded megathrust earthquakes, which anyone living in a subduction zone learns to fear.
The May 26th, 2009 quake, however, happened in a completely different part of the plate. In the southern Ecuador to central Peru region, the Nazca plate subducts at a very shallow 10° angle for hundreds of kilometers before it begins a steeper descent into the mantle. This "flat-slab" subduction doesn't tend to generate volcanoes, and also tends to produce large intermediate-depth earthquakes within the descending slab itself. This quake happened right at the 110km mark, and that is what made the vast majority of the difference.
Intermediate-depth earthquakes are far less catastrophic than the shallow intra-plate quakes. These earthquakes, which generally take place between 70 and 300km beneath the Earth's surface, can be felt strongly over a wide area, and can cause quite a bit of havoc, don't shake things quite as strongly as their same-magnitude shallow cousins. It's the difference between a bomb going off just beneath the surface, and a bomb triggered deep within a mine.
This quake happened inland, east of the Andes, and no large bodies of water nearby means no tsunami. Intermediate-depth quakes aren't tsunamigenic in their own right, though they can trigger landslides. Without an accompanying tsunami, the damage is far more limited than it would be otherwise.
And in this case, the earthquake happened in a sparsely populated area, which also helped keep deaths, injuries, and damage down to a minimum. The epicenter was on the western edge of the Reserva Nacional Pacaya-Samira, and the largest nearby town is Lagunas, which is under ten thousand people.
All of these factors prevented the 2019 quake from having anywhere near the destructive power of its 2007 cousin. While still devastating to those who were injured, those who died, and those whose property was damaged or destroyed, its overall impact wasn't nearly as severe. So if you're on a subduction zone, hope that the Big One will be intermediate depth. But build like you're in for the full rip-9 just in case.