Magic was falsely taught by evil ones, not Solomon. The angels Harut and Marut, who taught magic in Babylon, made it clear they were doing so as a trial and not to blaspheme. People learned magic to sow discord between spouses, but it could not harm anyone without Allah's permission. Those who bought magic would have no place in paradise. Selling one's soul for magic's teachings was a vile price, if only people knew.