Appointments to the Supreme Court of the United States are made by the President. The president chooses a nominee based on the nominee’s ideological stances and on the nominee’s likelihood of getting confirmed. There can be other political factors that come into play as well.
The main thing that presidents today want is to put someone on the Court that will agree with their political and ideological stances. Democratic presidents want liberal justices, Republican presidents want conservative ones. The main thing that they are looking for is this ideological stance because (particularly if the nominee is young) this will allow the president to affect national politics for decades to come.
Presidents then need to think about getting the nominee confirmed. They will need to pick someone who has been relatively uncontroversial. Picking a nominee who has been controversial, or one who is clearly not qualified, will make it more likely that the nomination will be rejected by the Senate.
Finally, there can be other considerations. For example, if an African American justice retires, the president will surely nominate another African American to the position.
Thus, while we would like to think that presidents pick the most qualified possible person, the nominations are actually driven by politics as much as by anything else.