Why we don't use the least-square objective function for GLMs? I am familiar with OLS, in which we minimize the sum of squared residuals to obtain the estimator. Why do we not use the same approach for GLM, but instead use maximum likelihood estimation?

We sometimes do use least squares instead of maximum likelihood estimation. For instance, in a linear probability model, we assume a conditional binomial distribution, for which the loss function corresponding to maximum likelihood estimation is log loss.
$$
L(y,\hat y)=-\sum_{i=1}^N\left[
y_i\log\left(\hat y_i\right)+
\left(
1-y_i
\right)\log\right(
1-\hat y_i
\left)
\right]
$$
However, the common approach in a linear probability model is to minimize square loss, anyway.
There are legitimate criticisms of this, but they have not stopped people from doing their modeling this way, so it is not really true that we estimate GLMs with maximum likelihood instead of least squares.
When we do use maximum likelihood instead of least squares, however, we do so because maximum likelihood estimators have some excellent properties. They are consistent. They are efficient. If we know the likelihood, maximum likelihood estimation is tough to beat.
(MLE is tough to beat, not impossible to beat. For instance, James-Stein estimation beats maximum likelihood estimation, at least in some sense.)$^{\dagger}$
...and if you're wondering why we maximize something in GLMs when we minimize something in OLS, they're two sides of the same coin. The phrasing in "maximum likelihood estimation" discusses maximization of some likelihood function $L$, and the exact same parameter estimates would arise from minimizing $-L$. In fact, the square loss function in OLS is related to Gaussian maximum likelihood estimation in this same way: $\sum_{i=1}^N\left(y_i - \hat y_i\right)^2$ is the loss function that we would minimize, and $-\sum_{i=1}^N\left(y_i - \hat y_i\right)^2$ is the likelihood function that we would maximize, where either approach gives the same parameter estimates. Viewing a classical linear model as a GLM with a Gaussian likelihood and then estimating the coefficients via maximum likelihood estimation will result in the exact same coefficient estimates as the usual OLS.
$^{\dagger}$That sense is square loss. As has been pointed out in the comments, if an analyst values something other than square loss (whether it is unbiasedness or ease of explanation to a customer who is familiar with OLS but unfamiliar with and unlikely to trust James-Stein), OLS could be considered better.
