If you want an abstract criterion, it is known that a finitely generated profinite group is uniquely determined by its finite quotients (this is Theorem 3.2.9 of Ribes Zalesskii: if $G_1$ is a finitely generated profinite group, and $G_2$ is a profinite group with the same finite quotients, then $G_1\cong G_2$). Of course, if $G_1$ has rank $r$, then all finite quotients of $G_1$ will have rank $r$.

Conversely, suppose $G$ is a profinite group such that every finite quotient has rank $\leq r$ (and some finite quotient of has rank $r$). By The set of finite quotients forms a diagonalization argumentlattice, we may find since if one has epimorphisms $r$ elements of G\twoheadrightarrow A, G\twoheadrightarrow B$where$G$A$ and $B$ are finite groups, then one has a map $G\twoheadrightarrow H\leq A\times B$, such that the image in $G\twoheadrightarrow H\twoheadrightarrow A$ and $G\twoheadrightarrow H\twoheadrightarrow B$.

For any given finite quotient $G\twoheadrightarrow A$, consider the subset $Gen(A)\subset A^r$ consisting of $r$ elements which generate $A$. Since $A$ is finite, $Gen(A)$ is finite for all $G \twoheadrightarrow A$. By hypothesis, $Gen(A)$ is non-empty for all $G \twoheadrightarrow A$, and clearly if we have $G \twoheadrightarrow H \twoheadrightarrow A$ where $H$ is finite, then we have a set of generatorsmap $Gen(H) \twoheadrightarrow Gen(A)$.

Thus, these elements form we may choose for all $G \twoheadrightarrow A$ an $r$-tuple $g(A)=(a_1,\ldots, a_r)\in Gen(A)$, such that if $G\twoheadrightarrow H \twoheadrightarrow A$, then $g(H)\mapsto g(A)$. This follows by the lattice property of finite quotients: we may find $G \twoheadrightarrow \cdots H_i \twoheadrightarrow \cdots \twoheadrightarrow H_2 \twoheadrightarrow H_1$ an inverse sequence of finite groups such that for any $G \twoheadrightarrow A$, there exists $i$ such that $G \twoheadrightarrow H_i \twoheadrightarrow A$. Choose $g(H_i)$ inductively so that for each $j>i$, there exists $v\in Gen(H_j)$ such that $v\mapsto g(H_i)$. Then define $g(A)=\phi(g(H_i))$ for some $i$ such that there is a factoring $G \twoheadrightarrow H_i \overset{\phi}{\twoheadrightarrow} A$. Now, the collection $\{ g(A), G \twoheadrightarrow A\}$ defines a unique $r$-tuple in $G$ which determines a topological generating set for $G$, since the cosets of the groups $ker\{G \twoheadrightarrow A\}$ form a neighborhood basis of $1\in G$, and therefore any nested sequence of cosets of $ker\{G \twoheadrightarrow A\}$ determines a unique element of $G$.

1

If you want an abstract criterion, it is known that a finitely generated profinite group is uniquely determined by its finite quotients (this is Theorem 3.2.9 of Ribes Zalesskii: if $G_1$ is a finitely generated profinite group, and $G_2$ is a profinite group with the same finite quotients, then $G_1\cong G_2$). Of course, if $G_1$ has rank $r$, then all finite quotients of $G_1$ will have rank $r$.

Conversely, suppose $G$ is a profinite group such that every quotient has rank $\leq r$ (and some quotient of rank $r$). By a diagonalization argument, we may find $r$ elements of $G$ such that the image in any finite quotient of $r$ is a set of generators. Thus, these elements form a topological generating set for $G$.

Thus, $rank(G)$ is the supremum of ranks of finite quotients of $G$.