We'll get the CDF of $Y$, then differentiate it. For $y\ge 0$, $Y\le y$ iff $X_1\le\frac{yX_2}{1-y}$, which for fixed $X_2=x_2$ has probability $\int_0^{yx_2/(1-y)}f_1(x_1)dx_1$, with $f_1$ the pdf of $X_1$. Integrating over $x_2$ gives the CDF of $Y$, $\int_0^\infty dx_2 f_2(x_2)\int_0^{yx_2/(1-y)}f_1(x_1)dx_1$, with $f_2$ the pdf of $X_2$. Differentiating with respect to $y$ obtains the density $$\int_0^\infty dx_2 f_2(x_2)\frac{x_2}{(1-y)^2}f_1(\frac{yx_2}{1-y})=\frac{b^{a_1+a_2}y^{a_1-1}(1-y)^{-a_1-1}}{\Gamma(a_1)\Gamma(a_2)}\int_0^\infty dx_2 x_2^{a_1+a_2-1}\exp\frac{-bx_2}{1-y}=\frac{y^{a_1-1}(1-y)^{a_2-1}}{\operatorname{B}(a_1,\,a_2)}$$(on $[0,\,1]$, of course). In other words, $y\sim\operatorname{B}(a_1,\,a_2)$.