* Disabling power output when the cable is not connected to a computer, so that a metal object touching the spring pins can't create a dangerous short circuit
* Driving the LED
Maybe because MacBooks can be charged via both USB-C and MagSafe connector it forms part of the safety mechanism against frying your motherboard and/or against arcing during connection/disconnection. Especially on the higher-end of the spectrum (e.g. 16-inch MacBooks with 140W MagSafe).
Sort of like the same way electric car chargers handshake before throwing amps down the cable.
The MagSafe connector only has three distinct contacts (there are five pins, but it's mirrored), so there has to be some protocol translation between USB PD and the single control signal used in MagSafe.
Another thought was something to do with monitoring current or degradation but I cant see why they couldn’t do the same things from either the computer in the power adaptor or the computer in the actual computer.