While running NiceHash Miner Legacy (or any other official open-source miner), your PC or hardware is solving different mathematical equations and sending the results to NiceHash. These results are then used to create new cryptocurrencies (such as Ethereum, Zcash, or Monero), or for allowing transactions between them. For each such result, you get paid in bitcoins.
By using NiceHash Miner Legacy you are participating in an open marketplace for hashing power. There are many people on the market who buy hashing power that you and other miners provide to the network. Please be aware that you are not paid out directly by NiceHash, as other buyers are paying for hashing power that you provide. NiceHash provides an open marketplace and only enables you to rent out the idle computing power of your machine. That is why miners are also called sellers because miners sell the hashing power to other people - buyers. NiceHash does not have any control over prices and profitability of mining - everything is set by the open marketplace and people who participate in it.