Why some TRIACs have mouting base connected to the main terminal?
Why some TRIACs have mounting base connected to the main terminal (one such example: BT139)?


The chip is bonded to the metal tab to provide minimum thermal resistance to the heatsink.


  ... and how to deal with it? 


Very carefully.


  Does it need to be grounded if the user can touch the heatsink?


You can not ground the tab as it is part of the circuit. You use an insulating layer between the tab and the heatsink and an insulating bush for the shaft of the screw.



Figure 1. The mica washer insulates the tab from the heatsink. The plastic bushing insulates the screw from the tab.

The tab may be still live. You must prevent user access to the device. You may ground / earth the heatsink itself for additional safety (for trained personnel working on / debugging / repairing the device.