The foundational tension is framed already in Pirkei Avot: Rabbi Elazar ben Azaryah teaches that without Torah there is no derekh eretz and without derekh eretz there is no Torah (Pirkei Avot 3:17), while Rabban Gamliel the son of Rebbi teaches that Torah study is best combined with an occupation, since the exertion of both together keeps a person from sin, whereas Torah without labor eventually comes to nothing and leads to sin (Pirkei Avot 2:2).
Rav Samson Raphael Hirsch develops this into a fuller account: derekh eretz is culture itself, the path of social wisdom that preceded Torah by twenty-six generations and educates a person toward morality and order in his social life, and for the Jew culture and derekh eretz are meant to be identical, so that the complete person and the complete Jew are one and the same (Rav Samson Raphael Hirsch, Rav Samson Raphael Hirsch, Rav Samson Raphael Hirsch). Yet he is explicit that this embrace is conditional: he rejoices in culture that brings recognition of truth and refines the heart, but not when it is harnessed to sensuality and increases corruption, and he states plainly that without Torah, derekh eretz leads only to corruption (Rav Samson Raphael Hirsch). He illustrates this with the example of Greek culture, which elevated intellect and feeling, cultivated self-respect and restraint of base impulses, and thereby ennobled man's spirit and conduct (Rav Samson Raphael Hirsch); yet even when science, art, and culture of that same Hellenistic spirit shine only with a polished sensuality capable of leading to error, he holds that the vessel for something higher still remains, and the greater danger he identifies is specifically the sophisticated materialism of Rome, which mocks the good and the divine while outwardly avoiding open attack on religion (Rav Samson Raphael Hirsch).
The Rambam sets the countervailing boundary, ruling that we may not follow the statutes of idolaters or resemble them in dress, hairstyle, and the like, deriving this from the pesukim warning not to follow the practices of the nations and not to inquire after them, and he explains that the Jew must be distinct in dress and deed just as he is distinct in understanding and outlook, since Scripture states that Hashem has separated Israel from the nations (Mishneh Torah, Foreign Worship and Customs of the Nations 11:1-3).
Tehillim opens with the praise of one who does not walk in the counsel of the wicked, stand in the way of sinners, or sit in the session of scoffers, but delights in Torah day and night, comparing such a person to a tree planted by streams of water that bears fruit in its season (Tehillim 1:1-3) — a model of selective engagement that filters out the company and values one absorbs. Bamidbar likewise records the blessing that Israel is a people that dwells apart and is not reckoned among the nations (Bamidbar 23:9), underscoring the theme of distinctiveness even while living among the nations.
Bereishit records Hashem's call to Avraham to leave his land, birthplace, and father's house, promising to make of him a great nation through whom all the families of the earth will be blessed (Bereishit 12:1-3), establishing a model of engagement with the wider world aimed at being a source of blessing to it. Yirmiyahu's charge to the exiles to seek the peace of the city to which they were exiled and to pray for it, since in its peace they will have peace (Yirmiyahu 29:7), and the account of Mordechai dwelling as a Jew within the Persian capital of Shushan (Esther 2:5-10), both model constructive involvement in a host society's wellbeing without dissolving Jewish identity within it.
The Gemara in Avodah Zarah illustrates the risk side of such exposure directly: one sage who deliberately tested his restraint by going to the entrance of a brothel relied on the pasuk that discernment will guard him from scheming, read as Torah itself serving as the guard (Avodah Zarah 17b:1-3), while the account of the sage who confesses that he derived pleasure from a heretical teaching and was consequently ensnared by the authorities, reading the pasuk to remove one's way far from her as a warning against heresy, shows how readily enjoyment of outside ideas can lead to entanglement with forces hostile to Torah (Avodah Zarah 17a:3). The story of the daughter of Rabbi Chanina ben Teradyon, condemned to sit in a brothel after she had taken pleasure in Roman nobles praising her gait and had refined her steps to please them further, is brought as an example of how even a small indulgence of external approval can draw a person into corruption (Avodah Zarah 18a:4).
Rav Kook's writings pick up this same balance from the side of Jewish thought's relationship to human culture at large: he opens by questioning whether a general, undifferentiated notion of human culture can even serve as a stable basis for asking what the Torah has contributed to it (Maamarei HaReiyah 29:1), and he holds that Israel's greatness within the spiritual and moral and faith-based realm is itself the guarantee of its greatness in the social realm, since Israel is permeated by those great spiritual, moral, and faith-based forces (Maamarei HaReiyah 29:13). He further teaches that the common thoughts prevalent in a generation must be elevated and sanctified just as a private idea must be elevated, by tracing foreign notions back to their pure root so that they come to act for the good of the nation and the individual (Kevatzim MiKtav Yad Kodsho, Volume 2 3:63), and regarding idolatrous customs themselves he distinguishes between elements stemming purely from evil and corruption, which the Torah utterly distanced, and elements rooted in healthy natural feeling, whose good the Torah retained after a full process of clarification and purification (Kevatzim MiKtav Yad Kodsho, Volume 1 2:78). He also cautions that divine thought, when it finds the soul empty of learning, experience, and inner refinement toward the good, can itself be inverted into something monstrous, making the cultivation of a cultured inner and communal life, proper character, and social justice necessary preconditions for genuinely approaching divine thought (Kevatzim MiKtav Yad Kodsho, Volume 2 7:26).
Rav Kook elsewhere stresses the educational imperative of laboring with the community, including those whose intellectual leanings are elevated even if they have not yet properly turned their attention to Torah, teaching them with good sense how the external dimensions of goodness and divine service connect to the heights of inner wisdom (Ein Aya, Shabbat 2:200); in Igrot HaReiyah he criticizes circles that hastily and superficially imitate Western culture and its innovations in shaping national life, warning that such uncritical external conformity can lead to destructive internal division and corruption (Rav Kook (Igrot HaReiyah 984)).
The Alter of Kelm's Chochma uMusar likewise treats the integration of Jewish perfection with worldly refinement as one of the hardest tasks, noting the breakdown of proper education in his generation and founding an institution meant to channel youth along the path of both Torah and derekh eretz together, following the best pedagogy (Chochma uMusar (Alter of Kelm)).
The Meshekh Chokhmah stresses that the ways of Torah permit no deviation even by a hairsbreadth, contrasting this with Bilam's statement that Hashem overlooks iniquity in Yaakov, which the Meshekh Chokhmah reads as not applying to genuine wrongdoing but only to cases where no real focus is placed on it (Meshekh Chokhmah, Mattot:23), while the Alshekh distinguishes between the war fought by Hashem against external enemies and the war against the yetzer hara that lies in human hands alone, since everything is in the hands of Heaven except the fear of Heaven (Alshekh on Torah, Bamidbar 31:48) — both underscoring that the internal discipline of filtering influence is a human responsibility that cannot be relaxed.