Any electric current going through a wire will generate a magnetic field. Turning the wire around an axis (a coil) will strengthen the field.
Induction of the magnetic field is directly proportional to the rate of change of voltage. If you put DC across the wire, there is only one change (the start of the current flow). If it’s AC however, then the flow is always changing which therefore generates a constant field. Fun fact: this also works in reverse – a moving conductor in a magnetic field will induce a current in the coil of the magnet. It’s how electric guitars work.
See Faraday’s Law of Induction.
Latest Answers