  We investigate the properties of the coexistence phase of itinerant
antiferromagnetism and nodal $d$-wave superconductivity (Q-phase) discovered in
heavy fermion CeCoIn5 under applied magnetic field. We solve the minimal model
that includes $d$-wave superconductivity and underlying magnetic correlations
in real space to elucidate the structure of the $Q$-phase in the presence of an
externally applied magnetic field. We further focus on the role of magnetic
impurities, and show that they nucleate the Q-phase at lower magnetic fields.
Our most crucial finding is that, even at zero applied field, dilute magnetic
impurities cooperate via RKKY-like exchange interactions to generate a
long-range ordered coexistence state identical to the Q-phase. This result is
in agreement with recent neutron scattering measurements [S. Raymond et al., J.
Phys. Soc. Jpn. {\bf 83}, 013707 (2014)].
