We present both the observation and the magnetohydrodynamics (MHD) simulation of the M2.4 flare (SOL2017-07-14T02:09) of NOAA active region (AR) 12665 to understand the initiation mechanism of this eruptive flare, which is associated with a coronal mass ejection (CME) and produces a storm of Solar Energetic Particles (SEPs). The observation by the Atmospheric Image Assembly (AIA) on the Solar Dynamics Observatory (SDO) shows that the major topology of the AR is a sigmoidal configuration associated with a filament/flux rope, which could be well reconstructed in the nonlinear force-free (NLFF) field model. Persistent emerging magnetic flux and the rotation of the sunspot are observed with Magnetic Imager (HMI) on the SDO in the core region, in the timescale of hours before and during the flare, providing sufficient free magnetic energy accounting for the flare/CME. A high-lying coronal loop is seen moving outward in AIA EUV passbands, which is immediately followed by the impulsive phase of the flare. We perform the MHD simulation that uses the potential magnetic field extrapolated from the measured pre-flare photospheric magnetic field as initial conditions and adopts the sunspot rotation as the driving force. In our simulation, a sigmoidal magnetic structure and an overlying magnetic flux rope (MFR) form as a response to the imposed sunspot rotation. The MFR rises up and erupts like a CME. These simulation results are in good agreement with observation, and suggests that the the loss of MHD stability might be the main cause for this eruption.