It would appear as though it is a zero-sum game, i.e. whatever one player loses, another player wins, as opposed to for example, sports betting where the house always takes a spread no matter what.
So how do online poker sites make money?
They take a percentage of each pot, called the "rake."
As well as rake, the amount of money deposited on such sites is massive and so a significant chunk of money is made by the sites investing the collective bankroll. There are however strict rules to stop companies using more riskier investment strategies.
As an aside, if you're comparing one site with another it isn't enough purely to compare the rake level. Some of the rake can be reclaimed in loyalty schemes etc. How these operate varies greatly from site to site.
As others have mentioned the main way these sites make money is from rake, where a percentage of the pot or entry fee is taken.
It might also be worthy to note that there are some rake-free poker sites such as BetRaiser.
These sites generate their income mainly from the transfer/deposit fees when you move money in and out of the site. Some sites also use their online poker purely as a side line to win over traffic into their online casinos.
On average they take 5% of every pot, or 5-10% from every tournament entry fee. That is called rake. Rake is also present in real Casinos.
Another side way they make money is by owning the Credit Card processing company that takes your deposit. Often a deposit of say 1000 might show up as 1008 or something on your statement. Some books refund that but since 90% of players lose their entire stack it doesn't matter.
Some online sites will use favourable retail exchange rates/average exchange rates as a secondary source of income i.e. they can get favourable exchange rates with financial institutions, and the customer may be subjected to a less favourable rate upon deposit and withdrawal. They make the difference between these two rates.
This has anecdotally happened to me on pokerstars.