The paper presents results of a research on simulation of magnetic tip-surface interaction as a function of the lift height in the magnetic force microscopy. As expected, magnetic signal monotonically decays with increasing lift height, but the question arises, whether or not optimal lift height eventually exists. To estimate such a lift height simple procedure is proposed in the paper based on the minimization of the fractal dimension of the averaged profile of the MFM signal. In this case, the fractal dimension serves as a measure of distortion of a pure tip-surface magnetic coupling by various side effects, e.g. thermal noise and contribution of topographic features. Obtained simulation results apparently agree with experimental data.