Diatomic polar molecules are one of the most promising platforms of quantum computing due to their rich internal states and large electric dipole moments. Here, we propose entangling rotational states of adjacent polar molecules via a strong electric dipole-dipole interaction. The splitting of 1.27 kHz between two entangled states is predicted for MgF molecules in an optical tweezer array. The resolution of the entangled states can be achieved in a magic potential for the molecules where the rotational states have the same trap frequencies. The magic potential can be formed by tuning the angle between the molecules quantization axis and the linear polarization of trapping light, so-called magic angle. We calculate the magic angle for MgF molecules in a reasonable experimental condition and obtain that the trap frequencies of the two involved states can be matched within a few 10s of Hz. Establishing entanglement between molecules, our results provide a first step towards quantum computing using diatomic polar molecules.