At the time Nozick wrote Philosophical Explanations, the theories of conditionals advanced by David Lewis and Robert Stalnaker were still fairly new. Lewis' book Counterfactuals was published in 1973 and Stalnaker's work was published in a series of papers from about 1968 onwards. Previously there hadn't been any generally accepted account of how counterfactual conditionals worked. Lewis and Stalnaker both drew on Kripke's work in using possible worlds (PW) to explicate the logic of necessity and possibility. They advanced similar accounts, under which a conditional "if A then B" is true when in the closest PW in which A is true, B is also true. There were some differences between them and various complications, but this was the basic notion. Actually, for Stalnaker, it was intended as an account of indicative conditionals as well.
The Lewis and Stalnaker account proved popular, though there are now several others, so Nozick adopted it in order to explain his counterfactual theory of knowledge.
According to Lewis, it is only the closest PW that determines the truth of a counterfactual. If A is false in the actual world, but true in some other PWs, then we use a bunch of rules of thumb to determine which is the closest PW and check whether B is true in that PW. So, for example, "if I hadn't missed my train I would be in London by now" is true if in the closest PW in which my counterpart catches the train they are in London. Since the trains are fairly reliable where I live, this counterfactual comes out true. More distant worlds where weird things happen, or the laws of nature are different, or the history of the world is unlike ours do not contribute to the truth of the counterfactual.