The magneto-ionic structures of the interstellar medium of the Milky Way and the intergalactic medium are still poorly understood, especially at distances larger than a few kiloparsecs from the Sun. The three-dimensional (3D) structure of the Galactic magnetic field and electron density distribution may be probed through observations of radio pulsars, primarily owing to their compact nature, high velocities, and highly-polarized short-duration radio pulses. Phase 1 of the SKA, i.e. SKA1, will increase the known pulsar population by an order of magnitude, and the full SKA, i.e. SKA2, will discover pulsars in the most distant regions of our Galaxy. SKA1-VLBI will produce model-independent distances to a large number of pulsars, and wide-band polarization observations by SKA1-LOW and SKA1-MID will yield high precision dispersion measure, scattering measure, and rotation measure estimates along thousands of lines of sight. When combined, these observations will enable detailed tomography of the large-scale magneto-ionic structure of both the Galactic disk and the Galactic halo. Turbulence in the interstellar medium can be studied through the variations of these observables and the dynamic spectra of pulsar flux densities. SKA1-LOW and SKA1-MID will monitor interstellar weather and produce sensitive dynamic and secondary spectra of pulsar scintillation, which can be used to make speckle images of the ISM, study turbulence on scales between ~10^8 and ~10^13 m, and probe pulsar emission regions on scales down to $sim$10 km. In addition, extragalactic pulsars or fast radio bursts to be discovered by SKA1 and SKA2 can be used to probe the electron density distribution and magnetic fields in the intergalactic medium beyond the Milky Way.