Why is the Absolute value / modulus function used?
One use of it is to define the distance between numbers. For example, in Calculus, you may want to say "the distance between $x$ and $y$ is less than $1$". The way to write that mathematically is $|x-y|<1$. And you want to write it mathematically so you can work with it mathematically.
The notation $\vert x\vert$ for absolute value of $x$ was introduced by Weierstrass in 1841:
K. Weierstrass, Mathematische Werke, Vol. I (Berlin, 1894), p. 67.
Quoted from [1]
...There has been a real need in analysis for a convenient symbolism for "absolute value" of a given number, or "absolute number," and the two vertical bars introduced in 1841 by Weierstrass, as in $\vert z\vert$, have met with wide adoption;...
Extra information: Absolute is from the Latin absoluere, "to free from"; hence suggesting, to free from its sign.
[1] Florian Cajori, A History of Mathematical Notations (Two volumes bound as one), Dover Publications, 1993.
My take on a usage example of absolute value: $$ \min(x,y)=\frac{1}{2}(|x+y|-|x-y|) $$ $$ \max(x,y)=\frac{1}{2}(|x+y|+|x-y|) $$
In the context of real numbers the absolute value of a number is used in many ways but perhaps very elementarily it is used to write numbers in a canonical form. Every real number $a\ne 0$ is uniquely equal to $\pm \left |a\right|$. So if we define the sign function $s\colon \mathbb R\setminus\{0\}\to \{+,-\}$ given by $s(a)=+$ if $a>0$ and $s(a)=-$ if $a<0$, then: for all $a\ne 0$ in $\mathbb R$ we have $a=sign(a)\cdot \left | a \right |$. In a sense this is a way to build all the reals from the positive ones. This is all just a special case of the polar representation of complex numbers, a representation of utmost importance.