Given [itex]t\in N[/itex] the numbers modulo [itex]t[/itex], [itex]Z_t[/itex] form a semigroup under multiplication. This semigroup decomposes into two disjoint subsemigroups, say [itex]\Phi_t,\Psi_t[/itex], being respectively the numbers relatively prime to [itex]t[/itex] and the rest. The former is actually a group.
The mapping [itex]\kappa:Z_t\rightarrow Z_t[/itex] s.t. [itex]\kappa:n\mapsto n^3[/itex] is a semigroup endomorphism of [itex]Z_t[/itex], and because [itex]((n^3,t)=1)\equiv ((n,t)=1)[/itex], it's also a semigroup endomorphism of both [itex]\Phi_t[/itex] and [itex]\Psi_t[/itex]. Then [itex]n^3[/itex] will represent all of [itex]Z_t[/itex] iff [itex]\kappa:\Phi_t\rightarrow \Phi_t[/itex] and [itex]\kappa:\Psi_t\rightarrow \Psi_t[/itex] are both isomorphisms (by the Pigeonhole Principle).
[itex]\kappa[/itex] is a group endomorphism of [itex]\Phi_t[/itex], and will be an isomorphism iff the kernel, [itex]\{n\in Z_t:n^3=1\}[/itex] is just [itex](e)[/itex]. By Lagrange and Cauchy's theorems this will be the case iff [itex]3\nmid o(\Phi_t)[/itex].
If [itex]t[/itex] is prime then [itex]\Psi_t[/itex] is just [itex]\{0[/itex] mod [itex]t\}[/itex], and [itex]\kappa[/itex] is necessarily an isomorphism on [itex]\Psi_t[/itex]. In this case [itex]o(\Phi_t)=t-1[/itex].
All primes other than [itex]2[/itex] and [itex]3[/itex] are of the form [itex]6k\pm 1[/itex], so only when [itex]t=6k+1[/itex] will [itex]3\mid t-1[/itex]. Thus [itex]n^3[/itex] will represent all of [itex]Z_t[/itex] for primes [itex]2[/itex], [itex]3[/itex] and [itex]t=6k-1[/itex].
If [itex](r,s)=1[/itex], [itex]\Phi_{rs}\cong \Phi_r\bigotimes \Phi_s[/itex] as groups. So [itex]n^3[/itex] will not represent all of [itex]Z_t[/itex] if [itex]t[/itex] has any prime factor [itex]t=6k+1[/itex]. Morover if has a square factor, say [itex]t=s^2u, s>1[/itex], then [itex](su)\neq 0(t)[/itex], but [itex](su)^3=0(t)[/itex], hence [itex]\kappa:\Psi(t)\rightarrow \Psi_t[/itex] cannot be an isomorphism.
This proves that every number is a cube mod t only if t is a square free product of primes of the form 2, 3 and 6k-1 and that n is a cube mod t whenever [itex](n,t)=1[/itex] and [itex]t[/itex] is of the given form.