Are lower DPS fast moves better for defending Pokemon in gyms?
Solution 1:
The reason "low DPS" moves are better is not because they are low DPS. And in fact, not all low DPS fast moves are better for defending; it depends on the move.
It's because, with the attack speed penalty defenders suffer (as discussed in Venomous' answer), they are actually higher DPS. This is true both for fast moves and charge moves.
A generic example might be the following. (These numbers are taken from a calculator I have, and I'm not sure they're right, but they give the right idea anyway.)
Let's say we have a pair of Slowbros. One has Confusion, one has Water Gun. Water Gun does 6 damage every half second, for 12 DPS (ignoring STAB for now). Confusion does 15 damage every 1.5 seconds, for a 10 DPS (again ignoring STAB, and rounding).
Now add the 1.5 second delay. Water Gun now does 6 damage every two seconds, or 3 DPS, while Confusion does 15 damage every three seconds, or 5 DPS. Confusion is now clearly the superior attack for a defender.
Another consideration that some of the calculators take into account is energy. If a move generates more energy, it's better (since you get more charge attacks). But again, fast moves are penalized by the 1.5 second delay here too. So a move that gives higher EPS on offense will now give a lower EPS bonus on defense relative to the other attack; so if the DPS calculation you're looking at actually includes EPS as part of it, that may be relevant.
Now, the same for Charge Attacks, for completeness:
Let's say we have a pair of Blastoise. One has Hydro Pump, one has Flash Cannon. According to my calculator, Hydro Pump has a DMG of 90, DPS of 23.7, which means it takes around 4 seconds to fire. Flash Cannon has a DMG of 60, DPS of 15.4, meaning it takes around 4 seconds to fire. Both have Water Gun as their quick move, which has a DMG of 6, DPS of 12, so it takes 0.5 seconds to fire.
For a defender, though, these numbers are a bit different. Hydro Pump now takes 5.5 seconds to fire, as does Flash Cannon, and Water Gun takes a whopping 2 seconds! So now look at their stats:
Hydro Pump: 90/5.5 = 16.36
Flash Cannon: 60/5.5 = 10.91
Water Gun: 6/2 = 3.0
Hydro Pump is still better of course, but it is fired one time for every three times Flash Cannon is fired. That one time you get a +13 DPS, but Flash Cannon gives you +8 DPS three times. Thus, you're really comparing 13 to 24 (over 5.5 seconds of course).
On Offense, meanwhile, your Flash Cannon only had a tiny 3 DPS advantage over Water Gun, while Hydro Pump has a huge 11+ DPS advantage. So those three Flash Cannon firings give you +9 DPS while one Hydro Pump is over 11. Hence, hydro pump being the better move. (If you're a dodger, it's an even bigger advantage, as you have less time that you can't dodge, by the way.)
Now, I'm simplifying this some (ignoring STAB for one, which makes Hydro Pump better), but this gets the gist across: on defense, the DPS calculation is different due to the slower moves, and in particular the quick attack is very slow - so there is a significant advantage for the moves that charge more quickly.
One thing that's ignored here, by the way, is difficulty to dodge. That's something not taken into account by most calculators; but some charge attacks are much harder to dodge than others - think Body Slam versus Hyper Beam. Any idiot can dodge hyper beam, it's almost hard to dodge because it takes SO long to show up, but Body Slam is much harder as it has a very quick animation. See this thread on Reddit for example.
Solution 2:
The reason that a lower DPS move would be more advantageous for a defending Pokemon in a gym is that defending Pokemon have a delayed attack speed. From this thread:
The attack cycle of moves like confusion will still be longer than water gun, but with a static 1.5 tacked on to both, a move that took 3x as long for the attacker takes only 1.5x as long for the defender. ( .5 vs 1.5s & 2 vs 3s respectively).
Basically, while Zen Headbutt has higher DPS in general, it likely has lower DPS for a defending Pokemon, due to the delay factor it has due to being a defender.
Thus, in the example you gave, Confusion has 15 base power, while Zen Headbutt has 12. Without the delay, Zen Headbutt is quicker and its DPS is actually slightly higher than Confusion. However, due to the delay, you are dividing by larger numbers. Since the factor is static regardless of what move you are calculating the DPS for, Confusion will end up with a higher DPS.