We can see that $x$ must not divide the product of the other elements of $S$ because if it does,$$\mathrm{gcd}\bigg(x,\prod_{y\in S\setminus\{x\}}y\bigg)=x\geq \frac{x}{k}$$ for every $k\geq 1$ .Erdos has proved that every set $S$ with the above property must have $\pi(n)$ elements at most.
"Let $a_n$ be a sequence of positive integers with $1<a_1<\cdots<a_n\leq N$ which has the property:
(A) $a_i\nmid \frac{a_1\cdot a_2\cdots a_n}{a_i}$ for every $i=1,...,n$ .Then $n\leq \pi(N)$ holds"
(As it was asked) here is the
proof: We will see that if a proper choise of maximum number of elements not exceeding $n$ with the mentioned property exists,then we can construct another (equivalent) set of elements containing only prime powers.
Suppose that the maximum number of elements we can choose from $\{2,...,n\}$ with the mentioned property is $r\geq \pi(n)+1$.
It is impossible to have all elements prime powers because by the pigeonhole principle there will be 2 elements $p^a,p^b$ with $a<b$ and $p^a|p^b$ which means that the desired property does not hold for $p^a$.
So,there must be at least one element that can be written as $x=k\cdot m$ with $\gcd (k,m)=1$.
If $k$ does not divide the product of the rest elements and so does $m$, then we can pull out $x$ from the set and place $k$ and $m$ into the set ,having a new set with $r+1$ elements with property (A) holding true.
(of course no other of the elements is equal to $k$ or $m$ because this would again lead to a contradiction)
But this is a contradiction since $r$ is the maximum number of elements as we assumed.
So,without loss of generality we may assume that $k$ does not divide the product of the rest,but $m$ does.
This means that we can replace $x$ with $k$ in the set with property A) holding true.
We repeat the argument again until $k$ "drops" to a prime power.
( which lets us arrive at a contradiction for prime powers as we already mentioned at the beggining)
So, your set must have at most $\pi(n)$ elements.
On the other hand, if your set contains at least $\pi(n)+1$ elements it could contain 2 powers of the same prime,$p,p^m$ and so the gcd you want would be at least $x=p$ (or $x=p^m$).
I think it would be more difficult to determine the asymptotic size of $S$ depending on $k$ but certainly $|S|\leq\pi(n)$ holds for a random set $S$ as you require.