Consider a lever...
Place two masses $m_1$ and $m_2$ on opposite ends of a lever of length $L$---where should the fulcrum be placed for this lever to balance?
Letting $d_1$, $d_2$ be the distances from the point masses to the fulcrum, Archimedes tells us that
$$m_1 d_1 = m_2 d_2.$$
In modern terms, we would say that the masses are applying equal and opposite torque to the system under the influence of gravity.
Introduce a coordinate system and let $x_1, x_2$ be the positions of the point masses and $\bar{x}$ be the position of the fulcrum. Our equation becomes
\begin{align*}0 &= m_1 (x_1 - \bar{x}) + m_2 (x_2 - \bar{x}) \\
(m_1 + m_2) \bar{x} &= m_1 x_1 + m_2 x_2 \\
\bar{x} &= \frac{1}{m_1 + m_2} \left( m_1 x_1 + m_2 x_2 \right).
\end{align*}
We can repeat this argument for $n$ point masses $m_1, \dots, m_n$ located at $x_1, \dots, x_n$ to find that
$$\bar{x} = \frac{1}{\sum_{i=1}^n m_i} \sum_{i=1}^n m_i x_i.$$
One-dimensional case
Now consider a continuous density distribution $\rho(x)$ along an interval $I=[a,b]$. Take a partition of $I$ by $a=x_0<x_1< \dots<x_{n-1}< x_n=b$ and approximate with a Riemann sum, noting that the mass on each sub-interval is approximately the density at a point times the length of each interval. In effect, we are approximating by collapsing the mass on each interval into a point mass.
$$\bar{x} \approx \frac{1}{\sum_{i=1}^n \rho(x_i)\cdot(x_i - x_{i-1})} \sum_{i=1}^n x_i \cdot\rho(x_i) \cdot(x_i - x_{i-1})$$
which becomes exact upon taking the limit $n \to \infty$:
$$\bar{x} = \frac{1}{\int_I \rho(x) ~\mathrm{d}x} \int_I x \rho(x) ~\mathrm{d}x = \frac{1}{M_{total}} \int_I x \rho(x) ~\mathrm{d}x .$$
Notice that we are integrating the $x$-coordinate against density and then dividing by the total mass to find the center of gravity.
On to your case
Instead of $\bar{x}$ being a point on which our one-dimensional mass rests, we view $\bar{x}$ as being a line on which our bent wire balances. In effect, the torque about this line from a point mass (under the effect of gravity) depends on the $x$-coordinate and the mass located there.
Parametrize the curve $C$ with $\mathbf{r}(t)=( x(t), y(t))$ with $t \in [a,b]$, letting $\mathbf{r}(t)$ be suitably nice, i.e., one-to-one and smooth. Again, take a partition $a=t_0 < t_1 < \dots < t_{n-1} < t_n = b$. The mass of wire associated with each sub-interval $[t_{i-1}, t_i]$ will be approximately the length $\Vert \mathbf{r}(t_i) - \mathbf{r}(t_{i-1}) \Vert$ times the density $\rho ( \mathbf{r}(t_i) )$, with an $x$-coordinate of approximately $x(t_i)$. This leads to the Riemann sum
\begin{align*}\bar{x} &\approx \frac{1}{\sum_{i=1}^n \rho(\mathbf{r}(t_i))\cdot \Vert \mathbf{r}(t_i) - \mathbf{r}(t_{i-1}) \Vert } \sum_{i=1}^n x(t_i)\cdot\rho(\mathbf{r}(t_i)) \cdot \Vert \mathbf{r}(t_i) - \mathbf{r}(t_{i-1})\Vert \\
&= \frac{1}{\sum_{i=1}^n \rho(\mathbf{r}(t_i))\cdot \frac{\Vert \mathbf{r}(t_i) - \mathbf{r}(t_{i-1}) \Vert}{t_i - t_{i-1}} } \sum_{i=1}^n x(t_i)\cdot\rho(\mathbf{r}(t_i)) \cdot \frac{\Vert \mathbf{r}(t_i) - \mathbf{r}(t_{i-1})\Vert}{t_i - t_{i-1}}.
\end{align*}
Again, this becomes exact upon taking the limit $n \to \infty$:
$$\bar{x} = \frac{1}{\int_a^b \rho(\mathbf{r}(t)) \Vert \mathbf{r}'(t) \Vert ~\mathrm{d}t} \int_a^b x(t) \cdot \rho(\mathbf{r}(t))\cdot \Vert \mathbf{r}'(t) \Vert ~\mathrm{d}t.$$
Letting $\mathrm{d}s$ be the "arc-length element" $\Vert \mathbf{r}'(t) \Vert ~\mathrm{d}t$, we write this integral in the more familiar form
$$\bar{x} = \frac{1}{\int_C \rho(x,y) ~\mathrm{d}s} \int_C x \rho(x,y) ~\mathrm{d}s = \frac{1}{M_\text{total}} \int_C x \rho(x,y) ~\mathrm{d}s.$$
Repeating this argument for $\bar{y}$ gives
$$\bar{y} = \frac{1}{\int_C \rho(x,y) ~\mathrm{d}s} \int_C y \rho(x,y) ~\mathrm{d}s = \frac{1}{M_\text{total}} \int_C y \rho(x,y) ~\mathrm{d}s.$$