Force MacBook to drain the battery while connected to charger I leave my MacBook Pro on my desk nearly all the time, connected to the charger with the lid closed, connected to an external display.  I've heard this is bad for the battery health, and everyone in my office have to replace swollen batteries every couple of years.
I want to regularly discharge the battery, per Apple's recommendation, but I don't want to physically unplug it because that temporarily turns off the external monitor, and then I have to reconnect the monitor.  So I am looking for a software method of disabling the power input, to force the laptop to discharge its battery to 20% and then re-enable the power input.
Short answer

To the best of my knowledge there's no consumer software capable of doing this.

Long answer

Using software to disable the power input until your MBP is discharged to a certain level wouldn't actually achieve your ultimate goal (i.e. avoiding your external monitor from being temporarily disconnected). 

That's because disabling the AC power input (or more specifically, switching it from AC to DC) is exactly what's causing your external monitor to behave in this way, and there's no way for the hardware to discern why the AC power input is gone. In other words, it's not capable of telling the difference between an AC source being switched off, a power lead being unplugged, or some software just disabling the AC power input.

The only other way to try to achieve this is to get your MacBook Pro to use more power than what the charger is supplying for a period of time. While that's theoretically possible, in practice it's just not going to happen without something that will also act to override the System Management Controller (SMC). 

To explain that a little further, to get your MBP to try and use more power than is being supplied would involve stressing out the hardware, at which point the SMC kicks in to protect it, so any software would need to try and bypass the SMC as well. While it is possible to bypass some functions of the SMC, I really wouldn't recommend it, and in this case it's likely to cause much greater long-term problems than a swollen battery or a short-term problem like a disconnected external screen.