JFET as an amplifier
What is the functionality of R2 here

It's used to bias the gate to 0 volts. Because an N channel JFET works with a range of negative voltages on the gate with respect to the source, biasing this way ensures that the JFET conducts a few mA of current causing the source to rise to a positive value. At this point equilibrium is reached due to negative feedback.