As also stated by @GEdgar, the problem is equivalent to find the maximum number of mutually independent events, since we can consider an indicator random variable for each event.
Given the prime factorization of $n = p_1^{k_1} p_2^{k_2} \cdots p_m^{k_m}$, if $n$ is not a prime number, the answer is $$\color{blue}{R(n)=\sum_{i=1}^mk_i}, \tag{1}$$
else $R(n)=0$. Let us write $n = \prod_{j=1}^{R(n)}a_j$, where each $a_j$ is a prime number. Then, the events $A_1,\dots, A_{R(n)}$ are such that $$|A_j|=\frac{n}{a_j}, |A_jA_k|=\frac{n}{a_ja_k}, |A_jA_kA_l|=\frac{n}{a_ja_ka_l}, \dots. \tag{2}$$
For example, for $n=12=2×2×3$, we have $R(12)=3$, attained for the sets
$$ A_1=\{1,2,3,4,6,7\}$$ $$A_2=\{1,2,3,5,8,9\}$$ $$A_3=\{1,4,5,10\}.$$
Point 1: To see how $R(n)$ given in (1) is obatined, it is enough to focus on the probability of the intersection of all the sets $\cap_{j=1}^{R(n)}A_j$. For the above example,
$$\frac{1}{12}=\frac{1}{2}×\frac{1}{2}×\frac{1}{3}=\frac{6}{12}×\frac{6}{12}×\frac{4}{12},$$
which clearly shows that the maximum number of independent events $R(12)$ is $3$, which can be attained for the sets stratifying (2), shown to exist in points 2 and 3.
Point 2: To construct the events $A_1,\dots, A_R$, we can use a simple down-up method illustrated for the give example. From (2), $a_1=a_2=2,a_3=3$, we know that $$|A_1|=|A_2|=6, |A_3|=4$$ $$|A_1\cap A_2|=3, |A_1\cap A_3|=|A_1\cap A_3|=2$$ $$|A_1\cap A_2\cap A_3|=1.$$ First put $1$ in $A_1\cap A_2\cap A_3=\{\color{blue}{1}\}.$ Then, using new distinct members complete $A_1\cap A_2=\{1,\color{blue}{2,3}\}$, $A_1\cap A_3=\{1,\color{blue}{4}\}$,$A_1\cap A_2=\{1,\color{blue}{5}\}$. Finally, add the new distinct members to each set $A_1=\{1,2,3,4,\color{blue}{6,7}\}$, $A_2=\{1,2,3,5,\color{blue}{8,9}\}$, $A_3=\{1,4,5,\color{blue}{10}\}$ so that we have $|A_1|=|A_2|=6, |A_3|=4$.
Point 3: The procedure described in point 2 always has a feasible solution as the total number of required distinct members is less than $n$. Indeed, for $n=\prod_{i=1}^{R(n)}a_j$ by inclusion-exclusion principle the required number of elements can be obtained as follows:
$$\sum \frac{n}{a_j}-\sum \frac{n}{a_ja_k}+\sum \frac{n}{a_ja_ka_l}, \dots=n\left (1-\prod_{j=1}^{R(n)}\left (1-\frac{1}{a_j} \right) \right)=n-\prod_{j=1}^{R(n)}\left (a_j-1 \right)<n. $$