Electricity is delivered to your home as alternating current, but laptops and many other electronics use the simpler direct current. The power inverter on your laptop cord is responsible for switching current from alternating to direct.
Direct current (DC) electricity can be envisioned as flowing through conductive material in much the same way water does. The current moves through a circuit in one direction and at a constant voltage. This greater uniformity of current makes it ideal for powering laptops and other electronics.
While DC power is effective and easily controlled over short distances, it quickly dissipates when sent too far. DC power supply would only be able to practically deliver electricity to homes within a one-mile radius of a power plant, so an alternative is necessary. Alternating current (AC) electricity, which oscillates quickly between positive and negative voltage as they make their way through a circuit, can travel for long distances without significant loss, which makes it far more suited for power transmission.
Power inverters for laptops are usually large blocks found in the middle of the cord. These devices convert electricity from AC to DC so it can be safely used by the laptop. Each inverter generates electricity of a specific voltage intended for use with a specific computer, so they are not all interchangeable.
Some energy is necessarily lost inside the inverter during the converter process. While this is generally a small amount of electricity, power inverters continually convert electricity the entire time they are plugged in, regardless of whether your laptop is on or off. Devices like power inverters that constantly leach and waste energy when not in use are sometimes called energy vampires.