Based on the Kirchhoff scalar diffraction theory,the principle to choose sampling periods in the input plane,output plane and transformation function was analyzed in detail. The sampling theorem to design diffractive optical elements has been systematically established. The intensity distortion mechanism of output pattern at non-sampling points has been studied deeply. Taking designing a one-dimensional beam shaping element by Gerchberg Saxton algorithm as example, the relationship between the intensity distortion of output pattern at non-sampling points and the sampling period in the output plane was explored after giving the definitions of performance parameters to evaluate qualities of beam shaping element. These parameters include light efficiency and top non-uniformity. The effectiveness of sampling theorem in the input and output planes to design diffractive optical elements was validated by simulated experiments.