It’s quite simple.
When a channel or user turns on monetization for their YouTube channel, it means that they agree to let advertisements appear on their videos, which YouTube then charges advertisers for.
When a viewer clicks on an ad placed on your video, YouTube collects the fees and shares them with you, allowing you to profit from people viewing your videos.