What does right clicking with the sword equipped do?

Solution 1:

According to the minecraft wiki article on swords, it blocks arrows and reduces damage done by attacks:

Swords will be able to block attacks by holding the right click in the Beta 1.8 update. This will block arrows as well as other projectiles, but will reduce the player to a speed slower than sneaking. Swords and all other player-dealt damage will be reduced by half a heart (like before Beta 1.5).

Solution 2:

It is a block posture.

It decreases the damage taken from mobs' physical attacks, but not creeper's explosion because it is not a physical attack and it blocks projectiles, like arrows.

The disadvantage is that it decreases the movement speed.

Solution 3:

This is newly fixed / reimplemented blocking mechanic!

It is supposed to reduce damage done by mobs while you're in the blocking state.