I am finding it very difficult to cultivate mudita for people who are happier and have it all. I am finding it easy to have empathy for those who are suffering. But my ego feels threatened when I encounter happy people who are not even practicing dhamma or meditation. How do I train my mind? How to look at such situation when people are in better situation than me?
You see, our lives are set inside certain conceptual systems endowing them with relative meaning.
Sentient beings assume this system to be the world. In reality everyone's system is slightly different, depending on circumstances, culture etc. - but there are some common parts too.
As a sentient being grows up and starts constructing his/her world, it looks at the other sentient beings, to try and understand from their actions how the world works. If they are sad or happy about some things, we know those things must be important, and we make a note in our own systems.
Then we apply those rules to our own lives. "If other people are sad in this situation, I must be sad too." - that's one case, a linear 1:1 observation. "If other people are happy about something and I don't have it, I must be sad" - this is another case, an inference that depends on negation.
We do this automatically all the time. It's a kind of stereotype, an automatic assumption.
In Buddhism we train to be free from such things. We learn to see through our stereotypes and our assumptions. We learn to be free from them. The complete freedom from all conceptual boundaries is freedom from death and freedom from suffering the Buddha has taught.
Freeing up from such assumptions is a skill that can be developed. You learn it one time and you can use it to break out of other assumptions too. The key is to analyze the basic concepts at the root of the assumption. Once you see the root you must find the emotional connection to that root in your heart. You should meditate on it until you clearly see why this emotional connection is important to you. Once you clearly see it all the way to the bottom, it will dissolve with little to no effort. It's a matter of reconfiguring your system of assumptions to let go of the stereotype, and once you see it's emotional root it's a fairly trivial act, like removing a splinter.
In this particular case, you assume that happy people got something good that you are missing. Maybe they have family or maybe they have career. You assume that it must be important. You assume that's what makes them happy. As you can see, there's a whole bunch of assumptions on your part.
There's a large number of ways we can challenge and attack these assumptions, it depends on your style which one you choose. I will show you just one, but don't assume it is the only one, it's just an example.
You can say: I assume they are happy because they have something, and that I would be happy too, if I had the same. However, happiness comes not from the external circumstance or external possession. Happiness is quite literally a product of my mind, it is a chemical or energetic state generated by my mind. How is it generated? It is generated when in my mind there's no conflict, no discord. So if I can be in a simple peaceful state, just sitting - that's right there is a happy state. It is even better than a kind of happiness based on material success or on good worldly circumstances, because it is not subject to outside conditions. So why should I feel bad about not having the same happiness those people have, if I can have something much better?!!
This way you can stop feeling bad about yourself. This was just one example of constructing a narrative that flips your perspective. You can do it in a dozen other ways, get creative. The point is to learn to be happy with yourself. (Then eventually you can learn to live without relying on any such narratives at all, but that is the next jhana, out of scope for the present discussion)
Once you learn to love yourself and be at peace with yourself, then naturally you will feel compassion for other people who have lesser kinds of happiness than yours. And you will be happy for them when they will discover the kind of happiness that comes from the peaceful mind. At that point, you will rejoice with them, too - and it will be a real authentic joy.
The problem is most people don't understand what mudita really is and what the goal of it is. It's not to just unilaterally develop non jealousy and partake of joy in any kind of success that others enjoy. For example, if you resent Donald Trump, it's not mudita to do, "I hope he gets reelected again and he stays happy for a long time.".
It's only proper mudita if the vicarious joy is based on kusala Dhamma activities. That is, if Donald Trump behaves in accordance to the Dharma and enjoys success and happiness from those Dharmic activities, then it would be mudita to vicariously experience joy and hope he continues that type of kusala Dharmic activity and reaps the benefit of it for a long time.
I get the impression that mudita was originally intended as the ideal towards people who were virtuous, wise, knowledgeable -- well-behaved, generous -- not necessarily those who "have it all" in a material sense.
Maybe that's an easier or more natural situation in which to feel "joy" -- i.e. not because of how rich someone is, but because of how good they are.
Or as MatthewMartin mentioned in this answer it might also be an appropriate attitude toward laypeople who are not exactly "rich" but are content:
If there is food on the table, a comfortable place to sleep, and they have no complaints about their daily routine, then our jobs as Buddhists is to rejoice in their success (mudita).
I doubt whether MatthewMartin's was an orthodox Theravada answer -- I think might have been originally taught as being applicable or appropriate towards "good/successful Buddhist monks" -- but I thought it was an interesting and useful way to expand the concept to lay and non-Buddhist social relations.
Mudita below is called "unselfish joy". Ven. Buddhaghosa has some recommendations with regards to the practice of mudita bhavana.
Please read this excerpt from the Visuddhimagga (The Path of Purification) authored by Ven. Buddhaghosa in the 5th century. It's entitled "The Meditative Development of Unselfish Joy":
One who begins the development of unselfish joy should not start with dearly beloved person, a neutral person or hostile person. For it is not the mere fact that a person is dearly beloved, which makes him an immediate cause of developing unselfish joy, and still less so neutral or hostile person. Persons of the opposite sex and those who are dead are not suitable subjects for this meditation.
A very close friend, however, can be a suitable subject. One who is called in the commentaries an affectionate companion; for he is always in a joyous mood: he laughs first and speaks afterwards. He should be the first to be pervaded with unselfish joy. Or on seeing or hearing about a dear person being happy, cheerful, and joyous, unselfish joy can be aroused thus: "This being, verily, is happy! How good, how excellent!" For this is what is referred to in the Vibhanga: "And how does a bhikkhu dwell pervading one direction with his heart imbued with unselfish joy? Just as he would be joyful on seeing a dear and beloved person, so he pervades all being with unselfish joy" (Vibhanga 274).
But if his affectionate friend or the dear person was happy in the past but is now unlucky and unfortunate, then unselfish joy can still be aroused by remembering his past happiness; or by anticipating that he will be happy and successful again in the future.
Having thus aroused unselfish joy with respect to a dear person, the meditator can then direct it towards a neutral one, and after that towards a hostile one.
But if resentment towards the hostile one arises in him, he should make it subside in the same way as described under the exposition of loving-kindness.
He should then break down the barriers by means of impartiality towards the four, that is, towards these three and himself. And by cultivating the sign (or after-image, obtained in concentration), developing and repeatedly practicing it, he should increase the absorption to triple or (according to the Abhidhamma division) quadruple jhana.
Next, the versatility (in this meditation) should be understood in the same way as stated under loving-kindness. It consists in:
(a) Unspecified pervasion in these five ways: "May all beings... all breathing things... all creatures... all persons... all those who have a personality be free from enmity, affliction, and anxiety, and live happily!"
(b) Specified pervasion in these seven ways: "May all women... all men... all Noble Ones... all not Noble Ones... all deities... all human beings... all in states of misery (in lower worlds) be free from enmity, etc."
(c) Directional pervasion in these ten ways: "May all beings (all breathing things, etc.; all women, etc.) in the eastern direction... in the western direction... northern... southern direction... in the intermediate eastern, western, northern, and southern direction... in the downward direction... in the upward direction be free from enmity, etc."
This versatility is successful only in one whose mind has reached absorption (jhana).
When this meditator develops the mind-deliverance of unselfish joy through any of these kinds of absorption he obtains these eleven advantages: he sleeps in comfort, wakes in comfort, and dreams no evil dreams, he is dear to human beings, dear to non-human beings, deities guard him, fire and poison and weapons do not affect him, his mind is easily concentrated, the expression of his face is serene, he dies unconfused, if he penetrates no higher he will be reborn in the Brahma World (A v 342).
Buddhism teaches to be generous. During covid 19 lock down and many shop closes, I spent a little and fed many stray cats. I happy to see them still around and get healthier.
In this case, my body release plenty of oxytoxin which is joyful hormone so it's a win win scenario. Its applicable to charity works too.
Teacher also taught me in most cases, people are born rich, healthy, charming and in harmony family due to their good deed in past life. But if they overspend their credit or misused it then could suffer either now or sooner.
Additionally, as just came accross: Bante Thanissaro gave shortly a talk on Muditas purpose.
[sure good as comment, or adding to answer before]
Sadhu for effort wishing to go against this kind of stinginess, good householder.
One under the people incapable in such, are traders, and that goes deep in meaning, leading direct to the source of stinginess.
It's actually the most difficult of the four Brahmaviharas, good householder, yet very straight on the path.
Maybe some explainings here may help, as well as samples to practice.
Training by sharing merits and give aprove: Rejoice with others & sharing merits pattanumodāna & pattidāna
Also a recent talk on it: Happy for People You Don’t Like, by Bhante Thanissaro.
At 'least' a talk by late Ven. Nanaponika
To learn such under 'wester', modern people, marxists... such is merely impossible, so association is most supportive support.
metta & mudita
And the, there, reminding the Dhamma, toward release: Sukhita Sutta: Happy, but first things first, since envy-defilements can lead to similar, called househol-equanimity.
[Note that this isn't given for stacks, exchange, other world-binding trades, but to lead toward the 'Brahamas' and release]