What are the advantages of measure in mathematics? I am learning measure theory, and I have come to know that measure is generalization of length, area, volume etc. So why do we need to generalize these and what is the advantages of measure here?

Measures provide a natural way to extend integration onto various spaces. (manifolds, reals, integers, etc.) Given a measure space $(X,\Sigma,\mu)$, a simple function is the finite sum of characteristic functions $\phi = \sum_{j=0}^{m-1} \chi_{S_j}$, where $\bigcup_{j=0}^{m-1} S_j = X$ and they are mutually disjoint. $\phi$ can be assigned a integral
$$ \int \phi\,d\mu = \sum_{j=0}^{m-1} \mu(S_j)
$$
Based on this, any nonnegative measurable function $f:X \to [0,\infty]$ can be assigned a integral
$$ \int f\,d\mu = \sup\left\{ \int \phi\,d\mu \mid \phi \leq f, \phi \text{ simple} \right\}, \int_S f\,d\mu = \int f\chi_S\,d\mu
$$
On $\mathbb{R}^n$, the most important measure is the Lebesgue measure $\lambda$. It turns out to coincide with the usual geometric definition of area/volume, and with the Riemann integral
$$ \int_{[a,b]} f\,d\lambda = \int_a^b f\,dx
$$
Measures also provide a way to unify discrete and continuous summation. Consider the counting measure $\mu$, which evaluates to the number of elements in a set. Then for any sequence $\{x_j\}_{j=0}^\infty$,
$$ \sum_{j=0}^\infty x_j = \int x\,d\mu
$$
