In the current era, the environmental component of ESG is recognized as a major driver due to the pressing challenges posed by climate change, population growth, global warming, and shifting weather patterns. The environment must be considered a critical factor, and as evidenced by existing research, it is regarded as the dominant component within ESG. In this study, the ESG score is derived primarily from the environmental score. The increasing importance of the environmental, social, and governance (ESG) factors in financial markets, along with the growing need for sentiment analysis in sustainability, has necessitated the development of advanced sentiment analysis techniques. A predictive model has been introduced utilizing a nested sentiment analysis framework, which classifies sentiments towards eco-friendly and non-eco-friendly products, as well as positive and negative sentiments, using FinBERT. The model has been optimized with the AdamW optimizer, L2 regularization, and dropout to assess how sentiments related to these product types influence ESG metrics. The “black-box” nature of the model has been addressed through the application of explainable AI (XAI) to enhance its interpretability. The model demonstrated an accuracy of 91.76% in predicting ESG scores and 99% in sentiment classification. The integration of XAI improves the transparency of the model’s predictions, making it a valuable tool for decision-making in making sustainable investments. This research is aligned with the United Nations’ Sustainable Development Goals (SDG 12 and SDG 13), contributing to the promotion of sustainable practices and fostering improved market dynamics.