In ferromagnetic materials,like iron, each atom has an unpaired electron. The orbital motion of this electron acts lke an electric current loop and generates a magnetic field. If "magnetized", a large faction of these atoms contribute to a magnetic field in one direction. With a bar magnetic, this field emerges from the north (seeking) pole, spreads out, and swings back around to reenter the south pole.(Magnetic field lines form closed loops.) The field of a bar magnet is the same as if an electric current were flowing around the outside of the bar.
If placed in an external field, a current loop or electron orbital is subject to a torque which tends to align its field with the external field. This is way a compass needle, or a floating magnet, tends to swing one end toward the north. In a spreading field, a current loop is subject to a force along the direction of the field, or the other way depending on the orientation of the loop. So a magnet in the field of another magnet is subject to a torque and\or a force. If an unmagnetized piece of iron is placed near a magnet, its atoms are subject to a torque which brings them into alignment, and they are then subject to an attracting force.