As you mentioned, Supreme Court Judges remain in office until they die or retire. That is typically many years or even decades after they are appointed, meaning that they will have a long time to argue their legal opinions whether it becomes the majority opinion or the dissent opinion.
At least since the 20th century (but probably longer), judges appointed by certain presidents tended to share political affiliations with said president at least to some degree. Or, in a shorthand, a conservative president would nominate conservative judges while a liberal or progressive president would nominate a more liberal or progressive judge.
I’m with you in considering the number of judges a president can nominate a question of luck. Moreover, a president doesn’t only need the luck of a vacancy occurring during their time in office but they also need a Senate that is likely to agree with their choice – as two thirds of the Senate were not elected at the time the president was last elected (and thus their campaign had far less influence on the Senate vote outcome), I am willing to file Senate composition as another element of luck in the appointment process.
However, the fact that Supreme Court Justices tend to stay in office far longer than a president means that even a single nomination can leave a far greater footprint. For example, Chief Justice Warren who retired conditionally (upon appointment of a successor) in 1968, effective in June 1969, saw the effect Nixon’s appointed successor, Chief Justice Burger, had on the Supreme Court and is quoted saying:
If I had ever known what was going to happen to this country and this Court, I never would have resigned. They would have had to carry me out of there on a plank.
Thus, the accomplishment doesn’t stem so much from the ability to name somebody but rather from the long lasting effects such a seemingly small act of one’s presidency has on the future – often far greater than most policies implemented.