Today, materials with unique nonlinear optical characteristics improve the function of optical devices. In this case, biological molecules with medical properties can be studied as a new group of materials with nonlinear optical properties. In this research, the optical features of some medically important molecules with piperazine ring were investigated in environments with different polarities. For this reason, spectroscopy and DFT methods were used. The polarity of an environment plays a significant role in improving the nonlinearity of solute molecules. Environment polarity induces the same effects on biomolecules’ hyperpolarizability in the first and second order. A comparison of environment polarity effects on the molecular linear and nonlinear optical characteristics leads to providing a simple method for studying the environment polarity effects on molecular nonlinearity. Moreover, selected materials with high nonlinearity can have a special place in optics and photonics