We have compiled optical and radio astrometric data of the microquasar LS 5039 and derived its proper motion. This, together with the distance and radial velocity of the system, allows us to state that this source is escaping from its own regional standard of rest, with a total systemic velocity of about 150 km/s and a component perpendicular to the galactic plane larger than 100 km/s. This is probably the result of an acceleration obtained during the supernova event that created the compact object in this binary system. We have computed the trajectory of LS 5039 in the past, and searched for OB associations and supernova remnants in its path. In particular, we have studied the possible association between LS 5039 and the supernova remnant G016.8-01.1, which, despite our efforts, remains dubious. We have also discovered and studied an HI cavity in the ISM, which could have been created by the stellar wind of LS 5039 or by the progenitor of the compact object in the system. Finally, in the symmetric supernova explosion scenario, we estimate that at least 17 solar masses were lost in order to produce the high eccentricity observed. Such a mass loss could also explain the observed runaway velocity of the microquasar.