[proofplan]
We count the same set of lattice points in two ways. The sum $\sum_{1 \leq n \leq x}\tau(n)$ counts ordered pairs $(a,b) \in \mathbb{N}^2$ with $ab \leq x$. Dirichlet's hyperbola method reduces this count to a sum over $a \leq \sqrt{x}$, where replacing floors by their main terms introduces only $O(\sqrt{x})$ error. The harmonic-number asymptotic then gives the constant term $2\gamma - 1$.
[/proofplan]
[step:Rewrite the divisor sum as a lattice point count below the hyperbola]
Define the divisor summatory function
\begin{align*}
S: [1, \infty) &\to \mathbb{R} \\
x &\mapsto \sum_{1 \leq n \leq x}\tau(n).
\end{align*}
Since $\tau(n)$ counts the positive divisors of $n$, we have
\begin{align*}
S(x)
&= \#\{(d,m) \in \mathbb{N}^2 : dm \leq x\}.
\end{align*}
Indeed, the map
\begin{align*}
(d,m) \mapsto dm
\end{align*}
identifies each ordered pair with a divisor $d$ of the integer $n = dm$, and every divisor $d \mid n$ gives the ordered pair $(d,n/d)$.
[/step]
[step:Apply the hyperbola decomposition at $\sqrt{x}$]
Let
\begin{align*}
y := \lfloor \sqrt{x}\rfloor.
\end{align*}
Every pair $(d,m) \in \mathbb{N}^2$ with $dm \leq x$ has either $d \leq y$ or $m \leq y$, unless both $d > y$ and $m > y$. But if $d > y$ and $m > y$, then $d,m \geq y+1 > \sqrt{x}$, so $dm > x$, which is impossible.
Therefore the union
\begin{align*}
A_x &:= \{(d,m) \in \mathbb{N}^2 : dm \leq x,\ d \leq y\},\\
B_x &:= \{(d,m) \in \mathbb{N}^2 : dm \leq x,\ m \leq y\}
\end{align*}
equals the full set $\{(d,m) \in \mathbb{N}^2 : dm \leq x\}$. By symmetry,
\begin{align*}
\#A_x = \#B_x = \sum_{1 \leq d \leq y}\left\lfloor \frac{x}{d}\right\rfloor.
\end{align*}
Their intersection is
\begin{align*}
A_x \cap B_x = \{(d,m) \in \mathbb{N}^2 : d \leq y,\ m \leq y\},
\end{align*}
because $dm \leq y^2 \leq x$ whenever $d,m \leq y$. Hence $\#(A_x \cap B_x)=y^2$, and inclusion-exclusion gives
\begin{align*}
S(x)
= 2\sum_{1 \leq d \leq y}\left\lfloor \frac{x}{d}\right\rfloor - y^2.
\end{align*}
[guided]
The divisor sum counts all integer lattice points below the hyperbola $dm=x$ in the first quadrant. The hyperbola method counts the part with first coordinate at most $\sqrt{x}$ and the symmetric part with second coordinate at most $\sqrt{x}$.
Set
\begin{align*}
y := \lfloor \sqrt{x}\rfloor.
\end{align*}
Define
\begin{align*}
A_x &:= \{(d,m) \in \mathbb{N}^2 : dm \leq x,\ d \leq y\},\\
B_x &:= \{(d,m) \in \mathbb{N}^2 : dm \leq x,\ m \leq y\}.
\end{align*}
If a pair $(d,m)$ satisfies $dm \leq x$ and is not in $A_x \cup B_x$, then $d>y$ and $m>y$. Since $d,m$ are integers, this implies $d,m \geq y+1$. Because $y=\lfloor \sqrt{x}\rfloor$, we have $y+1>\sqrt{x}$, and therefore
\begin{align*}
dm \geq (y+1)^2 > x,
\end{align*}
contradicting $dm \leq x$. Thus $A_x \cup B_x$ is exactly the set being counted.
For fixed $d \leq y$, the possible values of $m$ are precisely
\begin{align*}
1 \leq m \leq \frac{x}{d},
\end{align*}
so there are $\left\lfloor x/d\right\rfloor$ such integers $m$. Hence
\begin{align*}
\#A_x = \sum_{1 \leq d \leq y}\left\lfloor \frac{x}{d}\right\rfloor.
\end{align*}
By the symmetry exchanging $d$ and $m$, the same formula holds for $\#B_x$.
The overlap consists of pairs with both coordinates at most $y$. For such pairs,
\begin{align*}
dm \leq y^2 \leq x,
\end{align*}
so the hyperbola condition is automatic. Hence
\begin{align*}
A_x \cap B_x = \{(d,m) \in \mathbb{N}^2 : d \leq y,\ m \leq y\},
\end{align*}
and $\#(A_x \cap B_x)=y^2$. Inclusion-exclusion gives
\begin{align*}
S(x)
= \#A_x+\#B_x-\#(A_x\cap B_x)
= 2\sum_{1 \leq d \leq y}\left\lfloor \frac{x}{d}\right\rfloor - y^2.
\end{align*}
[/guided]
[/step]
[step:Replace the floor sum by the harmonic main term]
Let
\begin{align*}
H_y := \sum_{1 \leq d \leq y}\frac{1}{d}
\end{align*}
denote the $y$-th harmonic number. In this proof, the notation $R(x)=O(G(x))$ as $x \to \infty$ means that there exist constants $C>0$ and $x_0 \geq 1$ such that $|R(x)| \leq C|G(x)|$ for all $x \geq x_0$. For each $d \in \mathbb{N}$,
\begin{align*}
\frac{x}{d} - 1 < \left\lfloor \frac{x}{d}\right\rfloor \leq \frac{x}{d}.
\end{align*}
Summing this inequality over $1 \leq d \leq y$ gives
\begin{align*}
\sum_{1 \leq d \leq y}\left\lfloor \frac{x}{d}\right\rfloor
= xH_y + O(y),
\end{align*}
where the implicit constant is absolute. Therefore
\begin{align*}
S(x)=2xH_y-y^2+O(y).
\end{align*}
Since $y=\lfloor \sqrt{x}\rfloor$, we have $y=O(\sqrt{x})$, and hence $O(y)=o(x)$.
[guided]
The floor function is the only source of arithmetic irregularity in the hyperbola formula. We isolate it by comparing each floor with its real value. We use the notation $R(x)=O(G(x))$ as $x \to \infty$ to mean that there exist constants $C>0$ and $x_0 \geq 1$ such that $|R(x)| \leq C|G(x)|$ for all $x \geq x_0$. For every integer $d \geq 1$,
\begin{align*}
\frac{x}{d} - 1 < \left\lfloor \frac{x}{d}\right\rfloor \leq \frac{x}{d}.
\end{align*}
Define the harmonic number
\begin{align*}
H_y := \sum_{1 \leq d \leq y}\frac{1}{d}.
\end{align*}
Adding the floor inequalities for $1 \leq d \leq y$ yields
\begin{align*}
xH_y - y
< \sum_{1 \leq d \leq y}\left\lfloor \frac{x}{d}\right\rfloor
\leq xH_y.
\end{align*}
Equivalently,
\begin{align*}
\sum_{1 \leq d \leq y}\left\lfloor \frac{x}{d}\right\rfloor
= xH_y + O(y),
\end{align*}
with an absolute implied constant.
Substituting this into the hyperbola identity gives
\begin{align*}
S(x)
=2\sum_{1 \leq d \leq y}\left\lfloor \frac{x}{d}\right\rfloor-y^2
=2xH_y-y^2+O(y).
\end{align*}
Because $y=\lfloor \sqrt{x}\rfloor$, the error term satisfies $O(y)=O(\sqrt{x})=o(x)$. Thus the only remaining task is to evaluate $2xH_y-y^2$ to precision $o(x)$.
[/guided]
[/step]
[step:Evaluate the harmonic number at $y=\lfloor\sqrt{x}\rfloor$]
By the definition of Euler's constant,
\begin{align*}
H_y = \log y + \gamma + o(1)
\end{align*}
as $y \to \infty$. Since $y=\lfloor \sqrt{x}\rfloor$, we have $y \to \infty$ as $x \to \infty$, and hence
\begin{align*}
2xH_y = 2x\log y + 2\gamma x + o(x).
\end{align*}
Moreover,
\begin{align*}
0 \leq \sqrt{x}-y < 1,
\end{align*}
so
\begin{align*}
y^2 = x + O(\sqrt{x}) = x + o(x).
\end{align*}
Also $y/\sqrt{x} \to 1$, so
\begin{align*}
2\log y
= \log x + 2\log\left(\frac{y}{\sqrt{x}}\right)
= \log x + o(1).
\end{align*}
Multiplying by $x$ gives
\begin{align*}
2x\log y = x\log x + o(x).
\end{align*}
Therefore
\begin{align*}
2xH_y-y^2
= x\log x + (2\gamma-1)x + o(x).
\end{align*}
[/step]
[step:Combine the estimates to obtain the divisor summatory asymptotic]
From the previous steps,
\begin{align*}
S(x)
=2xH_y-y^2+O(y)
\end{align*}
with $y=\lfloor \sqrt{x}\rfloor$. Since $O(y)=o(x)$ and
\begin{align*}
2xH_y-y^2
= x\log x + (2\gamma-1)x + o(x),
\end{align*}
we obtain
\begin{align*}
\sum_{1 \leq n \leq x}\tau(n)
= S(x)
= x\log x + (2\gamma-1)x + o(x).
\end{align*}
This is the claimed asymptotic as $x \to \infty$.
[/step]