The Dirac delta function is not a simple function but rather a more abstract mathematical object. If you consider all of the ways you can linearly map functions to numbers (called a linear functional), a great number of the more useful ones can be expressed as integrals with respect to another function.
[tex]\phi_w: f\mapsto a = \int_{-\infty}^\infty f(x)w(x) dx[/tex]
(read ##\mapsto## as "is mapped to")
The choice of weighting function or distribution ##w## determines a large class of these linear functionals but not all. For example you cannot express the linear mapping that takes a function to its value at zero (or some other fixed point). ## f\mapsto f(0)##
There is no actual function but we can invent a notation, which looks like function notation but only has meaning as a place holder inside these functional integrals.
By definition:
[tex]\int_{-\infty}^\infty f(x) \delta(x) dx = f(0)[/tex]
We can then assert that this place holder obeys the same rules a functions inside of integrals with respect to change of variable, rules of differentiation and so on.
We can thus shift the variable of integration to get:
[tex]\int_{-\infty}^\infty f(x) \delta(x-a) dx = f(a)[/tex]
This is what we have to do to give the Dirac delta function rigorous meaning mathematically. In practice you can think of it as a "function" that is infinite at one point, zero everywhere else, and is normalized to integrate to 1. It is often expressed as the limit of e.g. Gaussian distribution functions in the limit as the standard deviation goes to zero.
It is of course very handy in physics applications where you are working in a paradigm of charge or mass densities but want to introduce a point mass or point charge. Another application is instantaneous changes in velocity where one can assert the applied force and thus the acceleration took the form of a delta function (of time).
In your case the delta function ## \delta(x - r(t))## is zero everywhere except where ##x=r(t)## at which point you have the infinite spike representing the charge density. Since again the total integral of the delta function is 1, multiplying by ##q## scales it to have total charge ##q##.