The Wikipedia entry for order statistics give some analytic results for the probability density function for various order statistics.
Given $X_1, X_2 \sim \operatorname{Gamma}(\alpha, \beta)$, and define $X_{(2)} = \max\left\{ X_1, X_2 \right\}$. Then, the distribution for $X_{(2)}$ is
$$ f_{X_{(2)}}(x)=\dfrac{\Gamma(3)}{\Gamma(2)} f_X(x) F_X(x)$$
Where $f_X$ is the density for the gamma distribution and $F_X$ is the cumulative distribution function. This should be fairly easy to simulate in R to
x <- replicate(100000, {
max(rgamma(2, 2, 1))
})
hist(x, probability = TRUE, ylim = c(0, 0.5))
curve(
gamma(3) / gamma(2) * dgamma(x, 2, 1)*(pgamma(x, 2, 1)), from = 0,
to = max(x), add=TRUE
)
Now consider the case where
$$ X_1 \sim \operatorname{Gamma}(\alpha, \beta) $$
$$ X_2 \sim \operatorname{Gamma}(\alpha ^\prime, \beta^\prime) $$
and again define $X_{(2)} = \max\left\{ X_1, X_2 \right\}$ where $X_1 \perp X_2$.
This means we can write the joint CDF as
$$ F_{X_{(2)}}(x) = \Pr(X_1 \lt x \cap X_2 \lt x) = F_{X_1}(x)F_{X_2}(x)$$
The joint density is then obtained by differentiating the above expression to yield
$$ f_{X_{(2)} } = f_{X_1}(x)F_{X_2}(x) + F_{X_1}(x)f_{X_2}(x) $$
Again, we can simulate this in R
x <- replicate(100000, {
x1 <- rgamma(1, 2, 1)
x2 <- rgamma(1, 2, 3)
max(c(x1, x2))
})
hist(x, probability = TRUE, ylim = c(0, 0.5), breaks = 100)
curve(
dgamma(x, 2, 1)*pgamma(x, 2, 3) + pgamma(x, 2, 1)*dgamma(x, 2, 3),
from = 0, to = max(x), add=TRUE
)