Why bothering in using your own resources, GPU, CPU, etc. on mining cryptocoins when you can trick others to make it for you? That’s what the people who use Coinhive think.
According to Krebs, “Coinhive is a cryptocurrency mining service that relies on a small chunk of computer code designed to be installed on Web sites. The code uses some or all of the computing power of any browser that visits the site in question, enlisting the machine in a bid to mine bits of the Monero cryptocurrency.”
That means that when someone visits site with Coinhive on it part of the resources from the device the user is using to browse the page will be used to mine for the person who put the code there.
Even though Bitcoin is the most famous cryptocurrency, Coinhive uses Monero for a good reason, it has a better privacy than Bitcoin. It is virtually untraceable, without a way others besides the parts of the transaction can track it. Their transactions automatically have privacy features applied. You never have to request and then verify whether other people have enabled a privacy mechanism when sending you funds.
The most common use of Coinhive is adding directly on the page, without the administrators permission many times, a part of code in the <head> </head> tags. With that and adding your public key for all the the Moneros you earn you are ready to let others do the mining
For more information on setting Coinhive and all of its uses you can check the documentation at https://coinhive.com/documentation/miner