There’s another aspect of going deep (not to contradict what’s been said, but to add to it).
Depth charges are unguided. Hitting (or getting close enough to rupture a hull) is a game of chance. You’re working in four dimensions – the sub maneuvers three-dimensionally in the ocean and a depth-charge attack takes time (the fourth dimension, for my purposes).
The charges are dropped off the stern of the ship, so you pass over the suspected location of the sub and drop them.
In WWII, sonar (I think we’re talking about active sonar mainly, the kind that “pings”) was blind right in front of the ship, and both sides knew it. Standard tactics, in addition to diving, were to maneuver at the last moment, just before the depth-charging vessel passed overhead, in an attempt to make the problem of hitting the sub harder by enlarging the possible area the sub could be in.
Think of depth charges falling from the surface – they take some time to sink. A deeper sub can move farther in that time before the charges reach its depth. Effectively, once the depth-charging vessel passes over the sub and is momentarily blinded, the sub’s possible position at that later point in time when the depth charges will go off is a cone, narrow at the surface and much wider around at the deepest part (“crush depth” for the submarine, in practical terms). A sub at the bottom of the cone could be anywhere in the wider circle the cone encompasses; one near the top of the cone has a much smaller circle to hide from the probabilities of being hit by a depth charge. The idea is to complicate the problem the depth-charging vessel’s captain (or relevant decision-maker) has to solve.
One way to attempt a solution is to drop a lot of depth charges at once, sort of a shotgun effect; the deterrent is that a ship only carried so many.
It’s worth noting that many depth-charged subs were not sunk outright, but forced to the surface after hours and hours of relentless depth-charging. The psychological effects were immense, much like being shelled for hours on land, and in much the same way often degraded the decision-making capabilities of those undergoing depth-charging or panicked them into surrender. Sometimes you don’t have to score a hit to win.
Edit: I see t-bonham@scc.net has preceded me with this idea. 