In this poem (pg 150 of the Guru Granth Sahib) Guru Nanak explains how he came to sing:
Hau dhadhi vekaar kaarey laayaa
I was a minstrel, out of work, when the Lord took me into His service.
My Lord and Master summoned me to the True Mansion of His Presence.
He has dressed me in the robes of His True Praise and Glory.
He asked me To sing His Praises day and night
The Ambrosial Nectar of the True Name has become my food.
Consuming the Guru’s Teachings, I am satisfied and have found peace.
His minstrel spreads His Glory, singing and vibrating the Word of His Shabad.
O Nanak, praising the True Lord, I have obtained His Perfection. ||27||Sudh||