Solution:
The pairs sought are those for which one of the three conditions a=b,a∤b or b∤a is satisfied, i.e., all pairs of positive integers except those for which one of the numbers a,b is a proper divisor of the other.
Throughout the entire proof we will denote the number of all divisors of a positive integer m by τ(m). First it is clear that in the case a=b one can choose an arbitrary n. Furthermore, in the case that a is a proper divisor of b, for every positive integer n the number na is a proper divisor of nb, so the set of its divisors is a proper subset of the set of divisors of nb, which implies τ(na)<τ(nb). The case b∣a,b<a is treated analogously.
It remains to show that in the case a∤b,b∤a we can always find an n with τ(na)=τ(nb). For this we first prove the following statement.
Lemma. Let α>β be positive integers. Then for every integer M>β there exists a positive integer γ such that
β+γ+1α+γ+1=1+M1=MM+1.
Proof. Rearranging the first equation gives γ=M(α−β)−(β+1)≥0. Now we consider the prime factorization a=∏ppαp and b=∏ppβp of a and b. Let p1,…pk now be all those primes p with αp>βp and q1,…,qℓ all primes q with αq<βq. Since a∤b,b∤a, both k and ℓ are positive. Let X now be a positive integer that is greater than all αp and βb. By the lemma above we can then choose numbers γ1,…,γk and γ1′,…,γℓ′ such that
βpi+γi+1αpi+γi+1=kX+i−1kX+i, and βqj+γj′+1αqj+γj′+1=ℓX+jℓX+j−1
holds for all 1≤i≤k and 1≤j≤ℓ. For n=(∏i=1kpiγi)⋅(∏j=1ℓqjγj′) it now follows, using the well-known formula
τ(p∏pηp)=p∏(ηp+1)
that
τ(nb)τ(na)=(i=1∏kβpi+γi+1αpi+γi+1)⋅(j=1∏ℓβqj+γj′+1αqj+γj′+1)=kXk(X+1)⋅ℓ(X+1)ℓX=1
so n is as claimed.