For a given $n$, let $P\subset\{2,3\dots,n\}$ be the set of primes up to $n$, and let $S\subset\{2,3\dots,n\}$ be any subset with pairwise coprime elements. Consider the function $f:S\to P$ that assigns to any $s\in S$ its smallest prime factor $p\in P$. It is clear that $f$ is an injection, whence $|S|\leq|P|$.
In short, the set of primes up to $n$ is the largest subset of $\{2,3,\dots,n\}$ with the given property.
Added 1. Péter Komjáth kindly called my attention to a 1962 survey by Paul Erdős (in Hungarian), which discusses some related problems. In particular, Problem 4 can be solved by the argument above: if $1\leq a_1<\dots<a_k\leq n$ are such that no $a_i$ divides the product of the other $a_j$'s, then $k\leq\pi(n)$. Problems 10 and 11 are based on a 1938 paper of Erdős and some later developments. Most relevant is Problem 18 that discusses the OP's question in general intervals. He denotes by $F(n,k)$ the maximal size of a subset $S\subset\{n+1,\dots,n+k\}$ with pairwise coprime elements, and he mentions that estimating this quantity is a difficult problem. In particular, he says that he is far from solving completely the problem of determining or estimating $\max_n F(n,k)$. I am sure that digesting the vast Erdős archive would bring up many related questions and results, in particular estimates for $F(n,k)$.
Added 2. The problem of estimating $F(n,k)$ (see previous section) is discussed in more detail in this 1971 paper of Erdős. See also the relevant OEIS entry.