"No, but I would to save two brothers or eight cousins."
As you share on average half your alleles with a brother and one-eighth with a cousin, Haldane was giving the number of relatives one would have to save to "break even".
As quoted in Mathematical Models of Social Evolution : A Guide for the Perplexed (2007) by Richard McElreath and Robert Boyd, p. 82;
https://en.wikiquote.org/wiki/J._B._S._Haldane
This is in relation to the idea of kin selection: https://en.wikipedia.org/wiki/Kin_selection
There are instincts that become ingrained as part of evolutionary process, and they are those instincts that correlate with genes that propagate more.
Thus, the genes that you inherited from your parents may activate an instinct that will make you sacrifice yourself (or at least reduce your chances to reproduce in the future), so long as that results in a larger portion of those inherited genes in the gene pool down the line - e.g. because some of your siblings, or even more distant relatives, survived to carry them on.
It's one other reason why "survival of the fittest" is really a very misleading way to put it - it's about "survival" of a particular package of genetic traits, not about survival of the species, much less individual specimen.
Evolution is a game of information propagation, in which actual living beings are heavily parallelized delivery channels, information transmitted is the configuration of channels, and there's non-random noise (environment) affecting signal propagation through those channels. The "winning" configuration is likely to involve some channels that do not transmit data directly, but are dedicated to performing error correction etc for other channels, that do transmit information about the entire configuration.
In fact, over time, you may even end up with a configuration that can dynamically allocate channels for error correction, if and when the noise becomes noticeable enough (i.e. environment gets more hostile), so as to not waste valuable bandwidth when it's not necessary. And then we call such things "altruism", "heroic sacrifice" etc.
The principle behind this is that evolution operates at the level of genes, rather than individuals. I recommend Richard Dawkins' The Selfish Gene for a fuller explanation.
E.g. suppose I have a loaf of lembas. I can eat it myself, and it increases my chance of surviving and reproducing merely by 10%, because, while I'm starving, I'm healthy. But I have three siblings who share 50% of their genes with me, and who are starving and sick. If I give all my lembas to them, their chances of surviving and reproducing increase twofold, and become same as my current chance. In that case, it makes sense for me (or rather my genes) to evolve the behavior whereby I give away the lembas, because these three survivors will spread the genes that we share more efficiently than I alone.
Now, obviously, the math here has to add up in real-world scenarios - is that what you mean by "it wasn't trivial to stack the dice"? It just feels like it shouldn't be hard to come up with many cases where all the coefficients line up...