This question refers to Book 1 of Vergil's Aeneid. Aeneas, after the fall of Troy at the hands of the Greeks, has made his way across the sea and finds himself and his companions shipwrecked in northern Africa at the town of Carthage.
One basic reason Aeneas was not seen was because his mother, the goddess Venus, had cloaked him in a mist (see lines 372-417).
Another reason that he and Achates are not harmed is alluded to in the question itself: they are strangers. Harming a stranger was regarded as a serious violation of social protocol. So, even though the Carthaginians and the Romans, the latter of whom could claim to descend from Aeneas, would eventually become enemies, social custom dictates that it is a crime the gods to injure a guest/stranger, especially one claiming to come in peace.
A third reason why no one harms Aeneas and Achates may have to do with Aeneas' destiny, to which we have alluded above. For Aeneas to be hampered in his journey at this point may have gone against the way that Aeneas' destiny was intended to unravel.
Historically speaking, Vergil's Roman audience would have recognized parallels between proto-Roman Aeneas and Dido (livin in northern Africa) and Julius Caesar and Cleopatra (Queen of Egypt). Cleopatra received Julius Caesar (who claimed to be descended from Venus) in a friendly fashion and Vergil's Roman audience might have expected Dido to receive Venus' son Aeneas in a similar manner.