"Bard" is a synonym for "poet." Shakespeare is known as the Bard of Avon because he wrote poetry and was from a town called Stratford upon Avon. The Avon is a river that flows through the town of Stratford, thus the "upon Avon" label. I wouln't say that Shakespeare was nicknamed "Bard"; that is, I don't think his friends would have used that instead of his name. Mostly English teachers and Shakespeare enthusiasts call him that.
Encyclopedia Britannica (link below) defines Bard as: "Celtic tribal poet-singer gifted in composing and reciting verses of eulogy and satire or of heroes and their deeds. The institution died out in Gaul but survived in Ireland"
It could be said that Shakespeare fits into the tradition of composing and reciting verses, and as he is considered the greatest of all time, he is known as "The Bard". He was also known as "The Bard of Avon", which is his hometown.
In 1769 the actor David Garrick wrote 'For the bard of all bards was a Warwickshire Bard'. It's not certain, but it may be the quote that started the nickname.