Cyclodextrin formulations are crucial for enhancing the solubility of drugs. Bile salts are recognized as potential agents for displacing drugs from cyclodextrin formulations in intestinal fluids. However, the mechanism underlying this displacement remains unclear. This study aims to investigate the mechanism of competitive displacement using molecular dynamics simulations and to develop guidelines for effective cyclodextrin formulation design. The umbrella sampling method is employed to investigate the binding free energy between bile salts and cyclodextrin molecules, while metadynamics is utilized to simulate the dynamic replacement process. The results indicate that the optimal binding free energy interval between cyclodextrins and drugs ranges from -30 kJ/mol to -8 kJ/mol. Additionally, the optimal concentration ratio between drugs and cyclodextrins can be calculated based on the binding free energy. Displacement simulations showed that free single bile salt molecules are more likely to complete the displacement compared to clusters of bile salts. This suggests that the bioavailability of cyclodextrins may be higher in fasting conditions than in the fed state. This study will not only enhance our understanding of the relationships between cyclodextrin formulations and bile salts but also facilitate the rational design of more effective pharmaceutical formulations.