When a video is played in YouTube, various types of advertisements are served alongside that video. Different companies pay YouTube to market their products and services and thus their advertisements appear on videos throughout YouTube's library.
When a user views a video in YouTube with an advertisement (or clicks on an ad), this is where the revenue is coming from.