It's not clear whether religions were invented for the reason of finding ultimate justice and happiness, but this reason is sometimes named as a justification for the existence of religions or for a person's religiosity.So... what then? They should invent a source of justice and happiness that can't be reached?
Bottomline, finding justice and happiness in this world is sometimes (and for some people, often) impossible. There seems to be no satisfactory solution to that problem.