The strength of shaking from an earthquake diminishes with increasing distance from the earthquake's source, so the strength of shaking at the surface from an earthquake that occurs at 500 km deep is considerably less than if the same earthquake had occurred at 20 km depth.
Also, the depths of earthquakes gives us important information about the Earth's structure and the tectonic setting where the earthquakes are occurring. The most prominent example of this is in subduction zones, where plates are colliding and one plate is being subducted beneath another. By carefully plotting the location and depth of earthquakes associated with a subduction zone, we can see details of the zone's structure, such as how steeply it is dipping, and if the down-going plate is planar or is bending. These details are important because they give us insight into the mechanics and characteristics of the deformation in the subduction zone.
The deepest earthquakes occur within the core of subducting slabs - oceanic plates that descend into the Earth's mantle from convergent plate boundaries, where a dense oceanic plate collides with a less dense continental plate and the former sinks beneath the latter. The plate boundary contact between two such plates generate very large, shallow subduction zone earthquakes such as the Sumatra 2004 M9.1 event, and the 2011 M9.0 Japan earthquake, and is only active to relatively shallow depths - approximately 60 km. However, because oceanic slabs are relatively cold with respect to the surrounding mantle in deeper subduction zone environments, faults within the core of these slab remain brittle and can generate earthquakes to depths of as much as 700 km (e.g., Pacific Plate beneath Japan and Kamchatka, and beneath Tonga).
As the slab descends into the mantle, rheology changes (viscosity characteristics) cause the plate to bend and deform, and generates these earthquakes. The trend of such events can be seen in cross-sections of subduction zones, and are known as "Wadati-Benioff Zones".
Within continents, and along continental plate boundary transform faults such as the San Andreas, faults are only active in the shallow crust - perhaps to depths of approximately 20 km.
Accurately determining the depth of an earthquake is typically more challenging than determining its location, unless there happens to be a seismic station close and above the epicenter. So generally, errors on depth determinations are somewhat greater than on location determinations.