The Rebbe's guidance to parents on the friends, company and surroundings that shape a child:
Surroundings shape a child more than anything else. People are naturally drawn after the views and conduct of those around them, so the environment a child grows up in comes first. Books and lessons matter, but the main thing is the school and the surroundings; if no suitable class exists, try to create one (IK 398).
Moving for the children's sake. When the children are of school age and the mother asks to move to a place of Torah and yiras Shamayim, her request is right, and G-d will provide for the family in the new place (IK 3037). But the family should not be split up: rather than the mother and children living apart from the father for the sake of schooling, it is better to send the older children to study elsewhere under the care of a trustworthy family (IK 3193).
Friends his own age reach a teenager best. With teenagers — especially one with a rebellious streak — words from friends his own age carry far more weight than requests or commands from adults. Arrange for friends to speak with him without his suspecting the parents asked, and try to give him a role leading or teaching a group of religious youth (IK 8365). Make sure a young child spends plenty of time with children his own age (IK 10056).
Practical safeguards. Keeping to religious dress naturally keeps a boy away from undesirable company; have him learn with a study partner so he is not isolated, and involve him with the most observant youth, even as a teacher of younger children (IK 4152). A teenager in constant conflict at home may do best studying away in a place of Torah, which ends the daily friction (IK 4300). During the transitional teenage years, act quickly to make sure a child is in a religious environment (IK 7432).
Whose company and whose teachings. A son raised in a Torah and Chassidus environment should not join a group led by people who reject those principles; the company a young man keeps is not a neutral matter (IK 7664).
See also: Parenting – Choosing a school or yeshiva for your child; Parenting – When a child drifts from Judaism and observance.