What is the cylinder on this wire? Is it some kind of adapter or transformer? What purpose does it serve? Why couldn’t it be incorporated into the primary adapter that plugs into the wall at the other end?

What is the cylinder on this wire? Is it some kind of adapter or transformer? What purpose does it serve? Why couldn’t it be incorporated into the primary adapter that plugs into the wall at the other end?

That’s a ferrite core. It’s just attached around the cable.
It behaves basically as a high-frequency transformer with a resistive load. Its function is to dissipate high-frequency energy as heat.
The most likely reason it’s there is because your device/computer could not pass electromagnetic emission testing without it. Too much of the internal signals are being conducted via the power cable, which then serves as an antenna.
It’s a lot cheaper and faster to attach a ferrite core than to find and fix the problematic spots in the PCB.
It's a ferrite core used to reduce common mode conducted EMI.
You can see an aftermarket clamp on type here:
It's called a "(inductive) choke."
The purpose is to add inductivity to the connection, so that very high frequency signals see high impedance (are filtered out) whereas the regular signal (power, or low-frequency data) is passed through largely unimpeded.
Generally, in the past, these chokes were put in to prevent the cable from acting as an antenna, and picking up RF energy from radio transmission, and in modern times, may also be put in to prevent high frequency switching noise from leaking out of whatever power supply is on the other side.