There is evidence that this ceremony was part of the Mass in Rome as early as the second century. The sign of peace was given after the general intercessions (formerly called the prayers of the faithful; now known as the universal prayer). Probably it was placed there because Jesus had said that if those bringing their gift to the altar recall that their neighbor has something against them, they should leave their gift there and go and reconciled.
In the fourth century, the peace ceremony was moved to a place after the Our Father - probably because of the final petition of that prayer: "Forgive us our trespasses as we forgive those who trespass against us."
Over the course of centuries, the peace ceremony came to be exchanged only among the clergy and, eventually, only at a solemn high Mass. It was given back to the whole assembly in the reform of the liturgy after the Second Vatican Council.
- Little White Book, Diocese of Saginaw