Impurity effects on spin dynamics in magnetic and superconducting iron pnictides and chalcogenides