The article studies the dynamics of pairwise entanglement of three qubits, two of which are trapped in a resonator and interact with a single-mode ideal resonator through single-photon transitions, and the third qubit is outside the resonator. This takes into account the dipole-dipole coupling between the isolated qubit and the qubit in the resonator. We have found a solution to the quantum nonstationary Schrodinger equation for the total wave function of the system for the initial separable and biseparable states of qubits and the thermal initial state of the resonator field. Using these solutions, the criterion of entanglement of qubit pairs - negativity is calculated. The results of numerical simulation of the negativity criterion have shown that the including of a small dipole-dipole coupling between an isolated and one of the trapped qubits can lead to significant entanglement of qubit pairs for all initial states. There is a transition of entanglement from one pair of atoms to other pairs of atoms during the evolution of the system. It is also shown that for some separable and biseparable states, the dipole-dipole interaction can suppress the effect of sudden death of entanglement