Electromagnets allow us to create controllable magnetic fields, i.e.: they act as magnets that we can turn on and off as we please but controlling an input voltage.
Compare them to permanent magnet: on a magnet, you always have a fixed generated magnetic field. But with an electromagnet you can control the field, and even turn it off entirely.
This type of "useful looking thing that can be controlled by a voltage" tends to be of huge importance in electrical engineering, the transistor being another example.