Question: When to use a generalized linear model over linear model?

I know that generalized linear model allows for example the errors to have some other distribution than normal, but why is one concerned with the distributions of the errors? Like why are different error distributions useful?

Answer: 
A GLM is a more general version of a linear model: the linear model is a special case of a Gaussian GLM with the identity link. So the question is then: why do we use other link functions or other mean-variance relationships? We fit GLMs **because they answer a specific question that we are interested in**. 

There is, for instance, nothing inherently wrong with fitting a binary response in a linear regression model if you are interested in the association between these variables. Indeed if a higher proportion of negative outcomes tends to be observed in the lower 50th percentile of an exposure and a higher proportion of positive outcomes is observed in the upper 50th percentile, this will yield a positively sloped line which correctly describes a positive association between these two variables.

Alternately, you might be interested in modeling the aforementioned association using an S shaped curve. The slope and the intercept of such a curve account for a tendency of extreme risk to tend toward 0/1 probability. Also the slope of a logit curve is interpreted as a log-odds ratio. That motivates use of a logit link function. Similarly, fitted probabilities very close to 1 or 0 may tend to be less variable under replications of study design, and so could be accounted for by a binomial mean-variance relationship saying that $se(\hat{Y}) = \hat{Y}(1-\hat{Y})$ which motivates logistic regression. Along those lines, a more modern approach to this problem would suggest fitting a relative risk model which utilizes a log link, such that the slope of the exponential trend line is interpreted as a log-relative risk, a more practical value than a log-odds-ratio.
Well, there are plenty of reasons to choose a different error distribution. But I believe that you aren't aware on why we have distributions for variables in the first place. If this is obvious to, I believe my answer is useless to you, sorry.

### Why distributions are important

See, having distributions allows us to consider a model in a probabilistic, meaning we can quantify uncertainties about our model. When in stat 101 we learn that the sampling distribution of the sample mean $\bar{X} \dot{\sim} \mathcal{N}(\mu,\sigma)$ (asymptotically), we can, in a probabilistic framework, tell a lot of stuff about that estimate, like testing hypothesis, constructing confidence intervals.

### Probabilistic Distributions in linear and generalized linear models

When in a linear model framework, we can basically do the same, if we know the the distribution of the error term. Why? This a result of linear combination of random variables ([see this answer](https://stats.stackexchange.com/questions/133312/distribution-of-linear-combination-of-ols-regression-coefficients)). But the point is, when this probabilistic structure is present in the model, we can again do sorts of stuff. Most notably, besides hypothesis testing and constructing C.I, we can build predictions with quantified uncertainty, model selection, goodness of fit testes and a bunch of other stuff.

Now why do we need GLMs specifically? Firstly, the probabilistic framework of a linear model can't handle different types of that, such as counts or binary data. Those types of data are intrinsically different them a regular continuous data, meaning its possible to have a height of 1.83 meters, but its senseless to have 4.5 electrical lights not working.

Therefore the motivation for GLMs starts with handling different types of data, primarily by the use of link functions or/and by cleverly manipulating the intended model to a linear known "framework". These needs and ideas are connected directly to how the errors are modeled by the "framework" being used.