What is this thing? It came attached to my camera AC adapter cord. I wasn't sure if it needed to remain on the cord. Looked like it might create a magnet running the cord through the same tunnel a few times. What does it do?
They're needed where any device might exhibit instability, data loss, unexpected behaviour, etc in the presence of electromagnetic interference; they're also needed to help reduce the amount of interference created by the cable itself.
For a simple explanation as to how they work, the object (also known as a ferrite bead) contains two pieces of a ferromagnetic material. If the interference is within a certain range of frequencies, the energy is contains will be 'absorbed' by the material and turned into heat - thus reducing the intensity of the interference. A more technical (and more accurate) description can be read here.
More often than not, they're simply there to meet a country's market regulations, rather than do anything particularly significant. They absolutely shouldn't be used everywhere - even though they're completely passive components, their presence in any circuit will have an impact on how it operates. A poorly chosen filter can make it operate worse.