What is the purpose of a resistor between the and gate output and ground?
First, let me tell you that this AND gate is one of the worst AND gate implementations. It has the several problems. Two of them:

1) It lacks regeneration (ok, this is a common issue on other discrete-component implementations too).

2) Under certain circumstances, it could not even work. If B is high (6V in your circuit), then the output will be: ( Vb - Vbe ) * R2 / (R1 + R2), where R2 is 4.7k and R1 = 10k. In other words, 1.69V. In some cases that value could be too high to be considered a "0".

Similar approach (just with a higher input current) could be achieved with a diode-resistor AND. Still, this would not have the issue of point 2.

That said, the 4.7 kOhm serves as pull down resistor, i.e. to create a "0" output signal, when A or B is "0". Furthermore, a "low" resistor value (few kOhms) is mandatory for the case of B = "1"  and A = "0" to work correctly (see point 2). In fact, if it were, let's say, 470 kOhm, with B="1" and A = "0" (Vb = 6V, Va = 0V) you would get Vout= 5.2 V, as the base-emitter junction would act like a diode...