The electro-optic (EO) effect is a powerful diagnostic tool for determining the time profile of ultrashort relativistic electron bunches. When a relativistic bunch passes within a few mm of an electro-optic crystal, its transient electric field is equivalent to a half-cycle THz pulse passing through the crystal. The induced birefringence can be detected with polarized femtosecond laser pulses. A simulation code has been written in order to understand the faithfulness and the limitations of electron bunch shape reconstruction by EO sampling. The THz pulse and the laser pulse are propagated as wave packets through the EO crystal. Alternatively, the response function method is applied. Using experimental data on the material properties of zinc telluride (ZnTe) and gallium phosphide (GaP), the effects of velocity mismatch, pulse shape distortion, and signal broadening are explicitly taken into account. The simulations show that the most severe limitation on the time resolution is given by the transverse-optical (TO) lattice oscillation in the EO crystal. The lowest TO frequency is 5.3 THz in ZnTe and 11 THz in GaP. Only the Fourier components below the TO resonance are usable for the bunch shape reconstruction. This implies that the shortest rms bunch length which can be resolved with moderate distortion amounts to $\ensuremath{\sigma}\ensuremath{\approx}90\text{ }\text{ }\mathrm{fs}$ in ZnTe and $\ensuremath{\sigma}\ensuremath{\approx}50\text{ }\text{ }\mathrm{fs}$ in GaP. The influence of the crystal thickness on the amplitude and width of the EO signal is studied. The optimum thickness is in the range from 100 to $300\text{ }\text{ }\ensuremath{\mu}\mathrm{m}$ for ZnTe and from 50 to $100\text{ }\text{ }\ensuremath{\mu}\mathrm{m}$ for GaP.