Hacker News sells inline advertising. Job posting adverts crop up pretty much daily on here which are adverts. It's a recruiting tool.
As for expenses, HN seems like a lean site and likely doesn't require a ton of resources. I think there is only 1 full time moderator, dang. I have no idea whether YC makes money on HN or not, but I'd be surprised if it didn't at least break even.