Just to clear up a misconception, teachers get a great pension, but (in Ontario at least) they put 10-13% of they're base salary into that pension plan for their entire careers. Anyone who invests that much money into their retirement will do well.
Also, the Ontario teachers pension plan is one of the best investment groups in the world. Many years they see 20+% returns. They own everything. Sports teams, malls, airports- they own the channel tunnel!
Are they doing well because they know the local market?
They still have big challenges though, as they have a lot of baby-boomer teachers retiring, living longer, etc. They only real way they stay afloat at all is because teachers are paid pretty well in Ontario, and they get that double-digit percentage of their paychecks. And with the high salary, there's a big over-supply of teachers wanting jobs, so no one is quitting over it.
https://www.thestar.com/yourtoronto/education/2015/11/22/fre...
http://www.theglobeandmail.com/news/toronto/ontario-schools-...
Here's an article (admittedly from 2012) on teachers salaries in Ontario: http://www.theglobeandmail.com/news/national/education/anato...
More recent reports (from the shrill National Post) claim an average salary of almost 87K for secondary school teachers, but they don't state their source information.
Also consider that teachers - like other public sector unions - are one of the last few sectors to get a defined benefit pension plan, a luxury that few others will ever have.