Why is the shoulder socket deeper than the hip socket?

It isn't. The hip socket is deeper than the shoulder socket. The shoulder socket is shallow to ensure a broad range of motion of the arm. The deep hip socket is for stability of the leg.