$\phi$ is multiplicative with $\operatorname{Id} = \phi * \mathbf 1 = \mathbf 1 * \phi$, i.e.
$$n = \sum_{d|n} \phi(d) = \sum_{d|n} \phi \left( \frac n d \right)$$
so the Dirichlet hyperbola method suggests how we can rewrite the sum of $\phi$ in terms of easier functions $\mathbf 1$ and $\operatorname{Id}$.
Starting with the sum of $\operatorname{Id}(m)$ as the triangle numbers $T(n)$:
$$T(n) = \sum_{m=1}^n m
= \sum_{m=1}^n \sum_{d|m} \phi \left( \frac m d \right) $$
The trick is now to exchange order of summations. Writing out this sum in rows for $n=6$:
\begin{matrix}
& d=1 & d=2 & d=3 & d=4 & d=5 & d=6 \\
m=1: & \phi(1) \\
m=2: & \phi(2) & \phi(1) \\
m=3: & \phi(3) & & \phi(1) \\
m=4: & \phi(4) & \phi(2) & & \phi(1) \\
m=5: & \phi(5) & & & & \phi(1) \\
m=6: & \phi(6) & \phi(3) & \phi(2) & & & \phi(1)
\end{matrix}
The first column, $d=1$, has totients $\phi(m)$. The second column, $d=2$, has totients $\phi(m/2)$ for $m$ divisible by 2. The third column, $d=3$, has totients $\phi(m/3)$ for $m$ divisible by 3, etc. Formally, by summing over the columns,
$$
\newcommand{\floor}[1]{\left\lfloor #1 \right\rfloor}
\sum_{m=1}^n \sum_{d|m} \phi \left( \frac m d \right)
= \sum_{m=1}^n \sum_{d=1}^n [d | m] \phi \left( \frac m d \right)
= \sum_{d=1}^n \sum_{m=1}^n [d | m] \phi \left( \frac m d \right)
= \sum_{d=1}^n \sum_{m=1}^{\floor{n/d} } \phi(m)
$$
Let $\Phi(n) = \sum_{m=1}^n \phi(m)$. This is the starting point of all the recursive algorithms:
$$
T(n) = \sum_{m=1}^n \Phi \left(\floor{\frac n m}\right)
$$
By a generalization to the Möbius inversion formula,
$$\Phi(n) = \sum_{m=1}^n \mu(m) \ T \left( \floor{\frac n m} \right)$$
Since $\mu(m)$ for range $[1,n]$ can be computed in linear time using a linear sieve, this gives a linear time and space algorithm. A small variation on the Sieve of Eratosthenes computes $\mu$ and primes in $O(n \log \log n)$ time.
However, the hyperbola shape of $\floor{n/m}$ suggests a sub-linear algorithm.
Rearrange to solve for $\Phi(n)$:
$$\Phi(n) = T(n) - \sum_{m=2}^n \Phi \left(\floor{\frac n m} \right)$$
The observation is that for large $m$ (consider $m \ge \sqrt n$), $\lfloor n/m \rfloor$ is constant for many values.
We can calculate precisely how many times each $\Phi( k )$ value occurs.
$$
\floor{\frac n m} =
\begin{cases}
1 & \text{if} \floor{n/2} < m \le n \\
2 & \text{if} \floor{n/3} < m \le \floor{n/2} \\
\vdots
\end{cases}
$$
Using this observation, we only recurse $O(\sqrt n)$ times:
$$\Phi(n) = T(n) - \sum_{m=2}^{\floor{\sqrt n}} \Phi
\left(\floor{ \frac n m } \right)
- \sum_{k=1}^{\floor{n / \floor{\sqrt n}} -1} \left( \floor{\frac n k} - \floor{ \frac n {k+1} } \right) \Phi(k)
$$
$k$ ranges from $1$ up to (but not including) the point where $\Phi(k)$ would overlap with $\Phi(\floor{n/m})$, which is at most one off from $\floor{\sqrt n}$.
The top-level call $\Phi(N)$ requires recursively computing and memoizing $\Phi(\floor{N/m})$ for $2 \le m \le \sqrt N$, and $\Phi(k)$ for $1 \le k \le \sqrt N$. For $\Phi(\floor{N/m})$ term, all recursive calls don't use any values not needed for $\Phi(N)$, as $\floor{\floor{N/m}/m'} = \floor{N/mm'}$. The same applies to recursive calls to $\Phi(k)$, as those contribute directly to $\Phi(N)$. So in total, to evaluate the about $2 \sqrt N$ terms $\Phi(\floor{N/m})$, each requires about $O(\sqrt{N/m})$ operations, assuming constant time memoized storage and lookup. The total computation is bounded by something like $\sum_{m=2}^\sqrt N O(\sqrt{N/m}) = O(N^{3/4})$. See this answer by Erick Wong for more details.
See this blog post by adamant for a more detailed explanation and details on using pre-computed prefix sums for an $O(n^{2/3})$ algorithm. The idea is that you can compute $\Phi$ and prefix sums up to $n^{2/3}$ in linear time with a linear sieve. Then we only need $\Phi(\floor{n/m})$ for $m$ up to $\sqrt[3]{n}$. In total the sums are computed in $\sum_{m=1}^{\sqrt[3]{n}} \sqrt{n/m} = O(n^{2/3})$. This is a little better than $O(n^{3/4})$ but at this point constant factors matter.