John was a very gracious Apostle. His Epistle clearly shows he was very gracious to women in "Beloved woman etc". He was also the first cousin of Jesus, being the son of Salome, the sister of Mary. Salome was alive and with Mary at the Cross. So Jesus was saying to his mother "Go and live with your sister and John, my beloved disciple, for whom I will provide and will be your provider. In this way you will know that I am still providing directly for you, as your faithful eldest son".
Jesus had four brothers, named in the Gospels, as Joseph, James, Judas and Simon. Why did He not give Mary to one of them, is the question. He also had an unknown number of surely married sisters as everyone was married then. The reason may be that their level of faith was the issue and Mary was very special.
I don't want to surmise without evidence but clearly Mary was very close to her sister, Salome, and her nephew John was a very special man, the only Apostle,as far as we know, faithful at the Cross and no doubt at that point, physically supporting his mother and aunt. The Cross was an experience that would have deeply bonded them. Clearly Jesus knew the whole story of the family, and his brother James did become a leader of the Jerusalem church and was martyred I think, but there is a suggestion that he was a trained priest.
Finally, maybe Mary just wanted to be with her sister and John and they were lovely faithful Christians, with a proven track record. She felt safe with them. John lived to a great age and possibly Mary did too, while many of the rest died violently quite young.