The role of a lightning rod on top of a building is to :
provide an easy route for the charges discharged by the clouds to the ground
The lightning rod provides easy route for the transfer of electric charge to the ground and thus protects the buildings from the effect of lightning.