Time-variable linear polarization as a probe of the physical conditions in the compact jets of blazars