Ampere’s law is used in this case because of the symmetry of the problem. Since the wire is infinitely long and the magnetic field is symmetric around the wire, the use of Ampere’s law simplifies the calculation.
Biot
-Savart’s law, on the other hand, is used for calculating the magnetic field due to a small segment of current
-carrying wire. For a finite wire, we would have to integrate over all the current elements. In the case of an infinitely long wire, using Biot
-Savart's law would require performing complex integration, which would not be as straightforward as applying Ampere's law.
Therefore, Ampere’s law is more convenient in this case due to the symmetry of the infinite wire, which leads to a simpler and more direct solution.