I've taught courses myself. We charge a lot but in my experience, it doesn't make money. It's just a social giving back thing. It's enough to cover costs of production, but not opportunity costs. But we charge because the people who come for the free courses often leave by lunch. Even when it's an expensive course paid in full by a company, people will skimp out because of "work" and it just wastes everyone's time.
It takes about 4 hours to produce 1 hour worth of slides and content. So the income can be worse than freelance coding, even when the hourly rate is higher.
Rule of thumb IMO is that the person teaching spends at least 80% of their time on the topic that they teach.