Effects of toroidal rotation and density profiles on the stability of an edge localized MHD mode are investigated numerically. From the numerical results we show that both the density gradient and the sheared rotation profile can destabilize the edge ballooning mode and the peeling–ballooning mode, and particularly, the sheared rotation can destabilize these modes effectively. To clarify the mechanisms of these destabilizing effects of density gradient and sheared rotation, we define some energies and distinguish them by physics. By comparing these energies, we clarify that the destabilization by the density gradient can be explained as the destabilizing effect of the centrifugal instability, and that by the sheared toroidal rotation is induced mainly by the difference between the eigenmode frequency and the toroidal rotation frequency of the plasma. Although the strong rotation shear also has a stabilizing effect on the MHD modes by changing the mode structure, the edge MHD mode first becomes unstable due to the appearance of the destabilizing effect before changing the mode structure.