How are unit maintenance costs and supply related?

Solution 1:

The supply limit based on your empire size is not related to the upkeep cost. Instead, if you exceed the supply limit, all your cities take a 10% production penalty. In most games, you will run out of money before you get to that point.

Solution 2:

Workers cost 9-11 gold for a pair. If you liberate (delete) one, you get no benefit. Liberate the second, and you'll get the 9-11Gold reduced from your maintenance costs.

Military seems to work the same, but I'm sure that it's not every pair. Riflemen come in a quartet (retire 3, no benefit. Retire the 4th, 9-11 gold).

I wasn't watching too closely, but I believe Barbarian Brutes cost 6G each (they may have been paired, I can't remember...).

Also, I don't know if death during combat counts towards the unit maintenance reduction.