Tasleem – Who Are We Saying Salam To?
Some act had to be introduced to end the prayer and hence saying Salam on both right and left sides was introduced. It could be taken as sending Salamti to the whole of humanity.
As a ritual of Ibadah, the main puspose of saying Salam is to end the Salah but it also serves another purpose of sending blessings upon brothers in congregation. One narration also points to this fact: https://sunnah.com/muslim:431a