This will depend on the exact wording of the will. If the will is well-drawn, it will provide alternative recipients in case the primary recipient of a bequest dies before the testator (will-maker) does.
But as a general rule, if A makes a will leaving particular property to B, but B dies before A does, that bequest is void. If the will specifies an alternate recipient, the property goes to the alternate. If not, or if all specified alternates die before the testator does, the property becomes part of the residual estate of the testator. (The residual estate is that part which is not subject to a specific bequest.)
The testator can specify a line of descent for a bequest: "I leave my house to Joan and her heirs". In that case, if Joan died before the testator, the house would go to whatever person or persons inherit from Joan. This was once a somewhat common form of bequest, but now is much less common.
A will normally includes language leaving the residual estate to some person (or several people) or some entity (it can be an organization, such as a church or a charity). This is often done with language such as "I leave all the rest of my estate to ..." OR "Everything not include above i leave to..." or "I give all the remainder and residue of my estate to...". The executor does not choose, but rather follows the directions of the will on who gets the residue of the estate.
I am not sure what happens if the will does not name a residuary legatee, or if the person so named dies before the testator. That will depend on the specific law of the jurisdiction. In the US, this means state law, and will vary from state to state.
The comment by Dale M says that assets not provided for in the will are inherited as if the person was intestate, that is, as if the person had no valid will. The law in each jurisdiction specifies exactly what rules are followed in the case of intestacy. In general this is that property goes first to the teatator's spouse and children, but if there are no living spouse and children, to more distant relatives. Eventually, if no relatives close enough can be found, property escheats, that is, goes to the government. The exact rule varies by jurisdiction -- in the US by state.