The Magnet is a utility item that will attract items and Experience Orbs to the player. The Magnet has a 7 block range by default.
To toggle the Magnet, either right-click with it in your hand or right-click on the item in your inventory.