Sri Krishna says in BG
कर्मण्येवाधिकारस्ते मा फलेषु कदाचन।
मा कर्मफलहेतुर्भूर्मा ते सङ्गोऽस्त्वकर्मणि।।2.47।।
Let your claim lie on action alone and never on the fruits; you should never be a cause for the fruits of action; let not your attachment be to inaction.
One's prArabdha (stored merit) will work most of the time, irrespective of one's sincere and steadfast efforts.
If efforts are being made for the benefit of others, the outcome will be according to the combined prArabdha (stored merit) of that particular segment of people.