Magnets stick to any metal that contains iron, cobalt or nickel. Iron is found in steel, so steel attracts a magnet and sticks to it. Stainless steel, however, does not attract a magnet.
Iron or steel are often added to other metals to make them stronger. The weaker metal will not attract the magnet, but the addition will. It is possible to test the purity of a metal with a magnet. Metals such as gold, silver, copper and brass will not draw into a magnetic field unless iron or steel has been added to them. Even a small amount of steel or iron makes the other metal stick to the magnet.