Why do you need 2 resistors when hooking up a transistor as a switch
There are two possible reasons:

As others have said, R2 acts as a pulldown in the case where the left end of R1 is left floating.  This is useful in when whatever driving R1 might go to high impedance.

As a voltage divider.  The B-E voltage of a silicon bipolar transistor is around 500-750mV when on.  In some cases you might want a higher threshold for the control voltage to turn on the transistor.  For example, if R1 and R2 are equal, then the transistor will start coming on at twice the voltage it would have without R2.