1) Our sages (see Brachos 7b) stress that the name of a person can affect his actions for the good or G-d forbid for the worse, [clearly one is able to overcome a bad name and cannot rely on a virtuous name alone, rather, one must strive to act in the most righteous way possible by doing mitzvos and learning Torah].
2) The Sefer Bris Avos (8:47) cites the Arizal as saying, “It is a mere misconception that a parent names a child arbitrarily. Rather, it is with Divine inspiration. For it is known before Him the purpose and (eventual) actions of the child, be it for the good or for the bad, all of which are concealed in his name. Each letter of the name reveals more and more about the person. Even if one finds an evil person with a name destined for the righteous, it is clear that contained in him is a small spark of goodness”. Rav Elimelech of Lischensk (Bamidbar) writesthat the name of a person is part of the deciding factor as to whether he will become a tzadik. He explains that it is predetermined, at the beginning of time, as to how many tzaddikim will be named Moshe or Shlomo (and the like). Therefore when a parent names a child Moshe (for example) he is tapping in to the righteousness of the original tzaddikim who shared that name, which effectively helps the child become virtuous in his own right.
3) It is currently customary to name after the child’s relatives (such as grandparents etc.) or great Tzadikkim (according to Ashkanazi tradition one should name only after the deceased, while many Sefardic Jews name after the living). The Sefer Mili D’Chasidusa (477) writes that naming after one’s parent or grandparent is a fulfillment of the obligation of kibbud av v’em, honoring one’s father and mother. A similar view was expressed by a student of Rav Nossan Adler zt”l, in the Sefer Rivam Shnaituch (Yoreh Deah 58). The reason being that (as stated above) when one names the child after a person he is connecting the child to his namesake,Therefore, by naming it after a grandfather (etc.) one is effectively saying “I wish my child would connect to the soul of my granfather and become like him”. This is obviously a great sign of honor.
4) Based upon the above teachings (that naming a child connects the child’s soul to whomever he is named after), it is quite obvious that one should not name a child after a rasha (wicked person), as this can affect the child in negative ways.
5) There are times where the only way to insure shalom bayis is by naming the baby after a relative who was not observant and the question arises as to whether this is permitted, The poskim offer possible heterim as to avoid any issue:
A- Rav Moshe Shternbuch Shlit”a (Teshuvos V’Hanhagos 2:50) explains that the child is only connected to his namesake regarding the mazal and middos of the deceased. The child is not connected to the actions of the departed. It seems to reason that one should be allowed to name the child after a non-observant Jew as long as he was a “good” person with excellent middos. In addition the poskim stress that most non-observant Jews cannot be classified as “wicked” because their actions are not meant to anger G-d, rather, they are due to lack of knowledge about Judaism and the Torah. They explain that these people are classified as “Tinok shenishba bein hanachrim”, a child lost amongst the nations.
B- Rav Shternbuch continues that if one alters the name of the child from that of the deceased, by adding a name, there would be no prohibition.
C- The poskim advise, that when the father says the name at the bris he should concentrate that the child is being named after the relative and after a tzaddik who shared said name. Therefore, if the name of the deceased was Yaakov, then the father should think that the child is being named after the family member and Yaakov Avinu, or any tzaddik named Yaakov (Mishneh Halachos 6:253, Yifai Nof 91, Teshuvos V’Hanhagos 2:501). Rabbi Moshe Weinberger Shlit”a added that if one forgot to do this during the bris one may be able to rectify this by calling the child (preferably daily or at least on Shabbos) using his full Hebrew name. And while speaking to the child he should concentrate on the tzaddik who shared this name.