Here's why:
* Preposition: "on" is the preposition.
* Object of the Preposition: "shore" is the noun that follows the preposition and receives its action.
Together, they form a phrase that modifies the verb "sang" by telling us where the sailor sang.