Lightning rods are mounted high on a structure and are connected to a wire that goes into the ground. The lightning strikes the rod and the electricity follows the wire.
Lightning (electricity) seeks the shortest distance to ground. Lightning usually strikes tall buildings or objects. A lightning rod is just a grounded metal rod place higher than surrounding objects.
An old invention, by acting as the highest point, lightening rods attract lightening and direct it towards the ground rather than letting it strike a roof.