I once had a relationship with a man 15 years older than me and in retrospect I can honestly say that I was subconsciously looking for a father/male authority figure and he seemed to fit that bill for me. Also, in retrospect, his deep fear of commitment was also a sign to me of emotional immaturity, so I guess I fit his bill as well in that sense.
It was a student/teacher relationship (not literally like your friends) where he had knowledge that impressed me and I had insights/optimism that excited him. Eventually those things worked against us, I wanted marriage and children and he seemed to be kicking and screaming the whole way, never wanting to settle down i.e. grow up. Not to mention completely different tastes in music, social and political views, fashion, you name it.
Now, I'm not saying it can't work out, but I will say it's likely that it won't and it's likely that this relationship is more about fulfilling subconscious psychological/emotional defecits. There's nothing a 40 year old man can give a 21 year old woman that a 21 year old man couldn't give her, and vice versa. Yes, men mature later and all that, but I don't think a woman at 21 has the capacity/life experience to give a 40 year old man what he needs, intellectually at least.
Ultimately it's all relative and dependent upon the level of maturity, experience, perspective, etc. but the likeliness of it being healthy and long-term IMO are not good. My grandparents are 15 years apart and have been married 50 years, but there were a lot of problems, a lot of infidelity (i.e. seeking fulfillment with people your own age) etc.
The fact that he was her teacher is really gross IMO, if he has romantic feelings for her now it means some seed was planted when she was a minor, and I find that sick. I think both of them should seek professional counseling to make sure they're not together because they have other subconscious issues.
The novelty of the age gap tends to wear off sooner than either person would like.