Given a differential equation, say: $$y''+2y'+y=0$$ we might get two equal roots to the characteristic polynomial.
Here we get $r_1=r_2=-1$.
So, $e^{-x}$ is a solution. In order to get another independent solution for $e^{rx}$, usually, $xe^{rx}$ is taken.
It is clear to me that $e^{rx},xe^{rx}$ are independent. But, how do we know that $xe^{rx}$ is also a solution to the original differential equation?
Consider the differential equation $$y'' - 2 r y' + r^2 y = 0.$$ Its characteristic polynomial, $\lambda^2 - 2 \lambda r + r^2 = (\lambda - r)^2$ has a double root at $r$.
If you simply want to verify that $x e^{r x}$ is a solution, all you have to do is substitute that expression for $y$ in the differential equation.
If your question is, How might we discover that solution in the first place?, we can proceed as follows: First, rewrite the differential equation as $$(D - r)^2 y = 0,$$ where $D$ denotes the derivative. First, suppose that $(D - r) y = 0$, that is, $y' = ry$: We then have $y = C e^{r x}$. So, any solution to $(D - r)^2 y = 0$ satisfies $(D - r) y = C e^{r x}$ for some $C$, that is, satisfies the differential equation $y' - r y = C e^{r x}$. Multiplying both sides by the integrating factor $e^{-r x}$ gives $$(e^{-rx} y)' = e^{-r x} y' - r e^{-rx} y = C,$$ so for $C \neq 0$ $$e^{-rx} y = C x,$$ hence $$y = C x e^{r x} .$$
Remark 1 We can iterate the above process to extend the result to roots of higher multiplicity, hence showing that for the homogeneous, linear, constant-coefficient o.d.e. with characteristic polynomial $(\lambda - r)^m$, namely, $$\sum_{k = 0}^m (-1)^{m - k} {m \choose k} y^{(k)},$$ all of $$e^{r x}, x e^{r x}, \ldots, x^{m - 1} e^{r x}$$ are solutions.
Remark 2 It's likewise little trouble to generalize the statement to any homogeneous, linear, constant-coefficient o.d.e. $$\phantom{(\ast)} \qquad y^{(n)} + a_{n - 1} y^{(n - 1)} + \cdots + a_1 y' + a_0 y. \qquad (\ast)$$ Suppose its characteristic polynomial $\lambda^n + a_{n - 1} \lambda^{n - 1} + \cdots + a_1 \lambda + a_0$ has distinct roots $r_1, \ldots, r_k$ of multiplicities $m_1, \ldots, m_k$, respectively. By relabeling, we may assume a given root is $r_k$th and rewrite the differential equation as $$(D - r_1)^{m_1} \cdots (D - r_{k - 1})^{m_{k - 1}} (D - r_k)^{m_k} = 0.$$ In particular, all solutions of $(D - r_k)^{m_k} y = 0$, in particular all of the functions $e^{r_k x}, x e^{r_k x}, \ldots, x^{m_k - 1} e^{r_k x}$, are solutions of $(\ast)$.