What is the purpose of "underruffing" in bridge?
Here are some situations where underruffing might be required.

1) Execute a Throw In

Consider the following situation, where spades are trump and south is the declarer. The lead is with West and he leads a diamond. 

    -
    xxx
    -
    -

-         KQT
-         -
AKQ       -
-         -
    AJ9
    -
    -
    -


South holding the AJ9 of trumps needs two of the last three tricks.

West is on lead and leads a diamond and east holding the KQT of trumps ruffs with the Q.

Now South must underruff with the 9, forcing East to lead from the KT into the AJ.

If South overruffs with the A, then South has to lead from the J9 into KT, losing two tricks.

2) To avoid a Squeeze

On defense sometimes the defender is forced to underruff (discard a trump) to avoid being squeezed. This might well apply to declarer (but is probably unlikely).

For an example for defense, consider the following example:

          Txx
          KJxx
          xx
          KJxx

x                  xxxx
T9x                Qxx
KQJTxx             xx
T9x                Qxxx

          AKQJx
          Axx
          Axx
          Ax


You are East. South is declarer in small slam in spades after West preempts in diamonds (and showing 0-7 points in your system, just for the sake of this problem). 

West leads the DK which declarer ducks and west continues with the diamond J which declarer wins the A. At this point declarer has 11 tricks, and knows you hold both the HQ and CQ.

Now declarer plays AK of trump, and then ruffs a diamond in dummy with the T.

At this point, you must now underruff! If you throw a heart, declarer can draw trumps throwing 2 clubs and 1 heart from from dummy, play A, K of hearts and drop your HQ, setting up the HJ.

If you throw a club, declarer can play AK of clubs, and ruff a club, dropping your Q, with the HK as entry to the good CJ.

So you underruff with a trump. Now declarer can draw trumps, but since you discard after dummy, you can just follow his discards and avoid being squeezed.

3) Executing a Trump coup

Then there might be trump coup situations where declarer/defender is trying to shorten the trump holding (to avoid being on lead at the wrong time) and might choose to underruff. 

For an example on defense:

           xxx
           Qxx 
           xxxx
           Kxx
Txxxx              -
xxx                Jxxx
Txx                QJx
xx                 QJxxxx

          AKQJ9
          AKx
          AKx
          Ax


You are west. South is declarer in a small slam in spades. You lead a heart which declarer wins in hand. He plays the trump ace, and gets the bad news.

It looks like declarer now has two unavoidable losers, a trump and a diamond, but declarer tries his best.

He plays one more round of trumps, cashes his hearts, and plays the A and K of clubs to reach this position.

           x
           - 
           xxxx
           x
Txx              
-                   Immaterial
Txx                
-                 

          QJ9
          -
          AKx
          -


Declare now plays a club and ruffs it with the Q.

At this point, you must underruff!

If you throw a diamond, declarer can play diamond A,K and low diamond. You are left with nothing but trumps and are forced to ruff that (basically ruffing your partners trick), and then lead from the Tx into declarers J9, allowing declarer to make the small slam!

But, if you underruff, now when declarer plays diamond A, K and low, your partner can win it, and then your T becomes the setting trick.

So underruffing is not unheard of, and is sometimes required. There are probably more situations than described above, but I believe they(including 2 and 3 above) tend to appear rarely.