As a hunted fugitive, David faces the urgent need to secure his family's safety. To protect his parents, he places them under the care of a foreign king until he can find a permanent refuge. The primary approach among commentators is that David personally guided and led his parents to the king of Moab [מצודת דוד, מצודת ציון, רד״ק, ביאור שטיינזלץ]. Building on this, it is understood that he did not merely drop them off, but firmly settled them in the foreign land to ensure they were established in their temporary home [רד״ק].
While his family remained in Moab, David took shelter in a stronghold. This was a well-guarded, fortified location, such as a tower, a rocky cliff, or a hidden cave, where he could defend himself against attacks [מצודת ציון, רד״ק, ביאור שטיינזלץ]. He did not choose this location by chance; it was geographically close to Moab, which made the initial transfer of his family much easier [רש״י, מצודת דוד].
The arrangement in Moab was strictly temporary. His family was meant to stay only as long as David remained in his fortified hideout. The moment he departed, their time under the Moabite king's protection came to an end [רלב״ג]. Tragically, the conclusion of this period brought a devastating betrayal. When David eventually left his stronghold and moved to the forest of Hereth, the king of Moab broke his promise and slaughtered David's father, mother, and brothers.
From this horrific massacre, only one of David's brothers managed to escape. His survival was entirely due to the intervention of Nahash the Ammonite, who saved his life. This specific act of rescue is the famous kindness that David later recalls, remembering the great favor Nahash did for him [רש״י].