Magnetic fields influence the motion of electrical charges due to relativistic effects, which alter the perception of charge density based on the observer's frame of reference. When an electron moves alongside a current-carrying wire, it experiences the wire as compressed, leading to a greater density of positive charges compared to negative charges. This creates an attractive force on the electron towards the wire, illustrating the fundamental principles of magnetism. Additionally, the force experienced by the electron varies with its velocity, consistent with magnetic behavior. The discussion highlights the connection between electromagnetism and relativity, suggesting further exploration in resources like Griffiths' "Intro to Electrodynamics."