The condition that the largest common factor of $p$ and $q$ is $1$ is commonly written as $(p,q) = 1$.
As suggested, you can apply the Lebesgue criterion which states that a function is Riemann integrable if and only if the set of discontinuity points has measure $0$. In this case, you would first show that $f$ is continuous at the irrational points in $[0,1]$. It also turns out that this function is discontinuous at every rational point in $[0,1]$, but such points form a countable set of measure zero. The heavy lifting of proving integrability is just relegated then to the big, general theorem of Lebesgue.
A more instructive approach is to consider the behavior of this specific function and show that it is integrable using only the basic concepts pertaining to lower and upper sums. I assume you have learned that a function is Riemann integrable if the upper and lower sums become arbitrarily close as the partition mesh (length of longest subinterval) goes to $0$. We can do better and show the integral is $0$ by showing that for any partition the corresponding lower sum is $0$, and if the mesh goes to zero the upper sum can be made arbitrarily close to $0$.
Consider any partition $P = (x_0,x_1, \ldots,x_n)$ of $[0,1]$. Each subinterval $[x_{j-1},x_j]$ must contain an irrational number where $f(x) = 0$. Hence, the greatest lower bound is $m_j = \inf_{x \in [x_{j-1},x_j]}f(x) = 0$ and
$$L(P,f) = \sum_{k=1}^n m_j \,(x_j - x_{j-1}) = 0.$$
Now consider an upper sum with $M_j = \sup_{x \in [x_{j-1},x_j]}f(x)$,
$$U(P,f) = \sum_{k=1}^n M_j \,(x_j - x_{j-1}).$$
Given $\epsilon > 0$, choose an integer $N > 2/\epsilon$ so that $1/N < \epsilon/2$. Consider all rational points $r = p/q$ in $(0,1]$ with $(p,q) = 1$ and $f(r) = 1/q \geqslant 1/N$. Such points lie in the set
$$S_N = \{p/q \in (0,1]: (p,q) = 1, \,q \leqslant N \}$$
where the number of points in $S_N$ must be some finite integer $M$.
For example we have $M = 6$ for $S_4 = \{1, 1/2, 1/3, 2/3, 1/4, 3/4\}$.
Choose a partition $P$ with mesh $\|P\| = \max_{j}(x_j - x_{j-1}) < \epsilon/4M.$ There are at most $2M$ subintervals that contain points in $S_N$. On these subintervals $M_j \leqslant 1$ since $f(x) \leqslant 1 $ for all $x \in [0,1]$, and the contribution to the upper sum satisfies
$$\sum_{[x_{j-1},x_j] \cap S_N \neq \phi} M_j \, (x_j- x_{j-1}) < 2M \|P\| < \frac{\epsilon}{2}.$$
On the remaining subintervals which do not intersect $S_N$ we have only rational points where $q > N$ and $M_j < 1/N < \epsilon/2.$ The contribution to the upper sum satisfies
$$\sum_{[x_{j-1},x_j] \cap S_N = \phi} M_j \, (x_j- x_{j-1}) < \frac{\epsilon}{2}\sum_{[x_{j-1},x_j] \cap S_N = \phi} (x_j- x_{j-1}) < \frac{\epsilon}{2}.$$
Adding the contributions we find $U(P,f) < \epsilon$.
Thus for any $\epsilon >0 $ we have a partition $P$ such that
$$0 = L(P,f) \leqslant \int_0^1 f(x) \, dx \leqslant U(P,f) < \epsilon,$$
and, since $\epsilon $ can be arbitrarily small, $f$ is Riemann integrable with
$$\int_0^1 f(x) \, dx = 0.$$