With all due credit to Gauß, see the other answer, it seems to have been Adrien-Marie Legendre who first published this conjecturally. More precisely, on the last page of the introduction (p. 19) of the first edition of his Essai sur la théorie des nombres (1798), he says in a footnote:
Au reste, il est vraisemblable que la formule rigoureouse qui donne la valeur de $b$ [primes $\le a$] lorsque $a$ est tres-grand, est de la forme $b = \dfrac{a}{A \,log. a +B}$, $A$ et $B$ étant des coefficiens constans, et $log.a$ désignant un logarithme hyperbolique [i.e. $ln(a)$]. La détermination exacte de ces coefficiens seroit un problême curieux et digne d'exercer la sagacité des Analystes.
[My translation: "Besides, it is likely that the rigorous formula that gives the value of $b$ [primes $\le a$] when $a$ is very large, is of the form $b = \dfrac{a}{A \,log. a +B}$, where $A$ and $B$ are constant coefficients, and $log.a$ denotes a hyperbolic logarithm [i.e. $ln(a)$]. The exact determination of these coefficients is a curious problem, worthy for Analysts to exercise their sagacity."]
So in modern notation he conjectures that $\pi(x) \approx \dfrac{x}{A \ln(x) +B}$ with some constants $A, B$.
In the second edition of the same work (1808), he turned this into an entire section (§VIII) in the fourth part, starting on p. 394. He now claims that
$$\dfrac{x}{\ln(x)-1.08366}$$
is the best approximation, i.e. some time between 1798 and 1808 he made up his mind that of his constants, $A=1$, and $B\approx -1.08366$. In volume 2 of the extended third edition (1830), the last published in Legendre's life time, he sticks with this claim (fourth part, §VIII, p. 65).
The somewhat curious number $(\pm)1.08366$ has, somewhat unfairly, become known as Legendre's constant. According to the Wikipedia article, Chebyshev proved in 1849 that if the formula is valid for any $B$ at all, then the value must be $B=(-)1$, and according to the prime number theorem, it really is. So Legendre was actually right on his first account, just that one of his constants turned out to be much simpler than he thought.
It seems likely that Legendre came up with this independently from Gauß (if only because it seems Gauß conjectured the right constants rightaway).
It would actually be interesting to know where Legendre got his confidence from that those five decimals $.08366$ were right; because even though they are not that far off in the range for which prime number tables were available at that time, neither would have been some other numbers. Cf. https://www.mathpages.com/home/kmath032.htm. (E.g. sure, if we look at https://en.wikipedia.org/wiki/Legendre%27s_constant#/media/File:Legendre%27s_constant.svg, the blue line matches somewhat, but if we moved it up or down by $\pm 0.01$, it still would look reasonable; let alone going to $1.08361$ or $1.08379$ or ...) Likely there is something about that to be found in that §VIII of the fourth part of the later editions, which to be honest I did not read thoroughly now (and would lack understanding for anyway); maybe someone with better knowledge of number theory could help here.