For equilibrium, the magnetic force on the wire must balance its weight:
\[
F_{\text{magnetic}} = F_{\text{gravity}}.
\]
The magnetic force is given by:
\[
F_{\text{magnetic}} = I L B,
\]
where \( I \) is the current, \( L = 50 \, \text{cm} = 0.5 \, \text{m} \) is the length of the wire, and \( B = 0.40 \, \text{T} \) is the magnetic field.
The gravitational force is:
\[
F_{\text{gravity}} = mg,
\]
where \( m = 40 \, \text{g} = 0.040 \, \text{kg} \) and \( g = 10 \, \text{m/s}^2 \).
Equating the forces:
\[
I L B = mg.
\]
Solve for \( I \):
\[
I = \frac{mg}{L B}.
\]
Substitute the values:
\[
I = \frac{0.040 \cdot 10}{0.5 \cdot 0.40}.
\]
Simplify:
\[
I = \frac{0.40}{0.2} = 2 \, \text{A}.
\]
Thus, the required current in the wire is \( \boxed{2 \, \text{A}} \).