A similar passage in Luke:
Luke 10:5-6
5 Into whatever house you enter, first say, ‘Peace to this household.’
6 If a peaceful person lives there, your peace will rest on him; but if not, it will return to you.
See also Mark 6:8 . Here is the whole passage:
Matthew 10:12
12 As you enter a house, wish it peace.
13 If the house is worthy, let your peace come upon it; if not, let your peace return to you.*
14 Whoever will not receive you or listen to your words—go outside that house or town and shake the dust from your feet.
The note says: "The greeting of peace is conceived of not merely as a salutation but as an effective word. If it finds no worthy recipient, it will return to the speaker." Consider what happened after St Paul and St Barnabas were driven out of a city, and shook the dusk from their feet:
Acts 13:51
51 So they shook the dust from their feet in protest against them and went to Iconium.
52 The disciples were filled with joy and the holy Spirit.
See also:
Luke 2:14
14 “Glory to God in the highest
and on earth peace to those on whom his favor rests.”
Peace is effectively a blessing, the favor of the Lord. If the blessing finds no worthy recipient, it will fall back on those who gave it. Those who St Paul and St Barnabas gave peace to would not have that peace, so the peace of the Lord fell back on the two men, and they were "filled with joy and the holy Spirit".