Entanglement is essential in quantum information science. Typically, the inevitable coupling between quantum systems and environment inhibits entanglement from being created between long-distance subsystems and being maintained for a long time. In this paper, we show that when the environment is composed of a bath of massive scalar fields, the region of the separation within which entanglement can be generated is significantly enlarged, and the decay rate of entanglement is significantly slowed down compared with those in the massless case, when the mass of the field m is smaller than but close to the transition frequency of the qubits ω. When m ≥ ω, the initial entanglement can be maintained for an arbitrarily long time, regardless of the environmental temperature. Therefore, in principle, it is possible to achieve long-distance entanglement generation and long-lived entanglement by manipulating the energy level spacing of the two-level systems with respect to the mass of the field.