What is the function of this npn transistor?
The entire circuit is a constant current sink for the LED. 

The 19V through the 47K R306 turns the MOSFET on until the voltage across the E-B resistor R3?? reaches about 0.6 or 0.7V, at which point the NPN transistor turns on and limits the gate voltage by diverting some of the current through R306 to ground.  

The constant current is thus about 0.7/R3?? and the LED can have up to almost 19V across it. The waste heat is dissipated by the MOSFET, the NPN transistor runs very cool.