The mechanisms of the misfit strain relaxation in heteroepitaxial islands are investigated in two-dimensional molecular dynamics simulations. Stress distributions are analyzed for coherent and dislocated islands. Thermally-activated nucleation of misfit dislocations upon annealing at an elevated temperature and their motion from the edges of the islands towards the positions corresponding to the maximum strain relief is observed and related to the corresponding decrease of the total strain energy of the system. Differences between the predictions of the energy balance and force balance criteria for the appearance of misfit dislocations is discussed. Simulations of an island located at different distances form the edge of a mesa indicate that the energy of the system decreases sharply as the island position shifts toward the edge. These results suggest that there may be a region near the edge of a mesa where nucleation and growth of ordered arrays of islands is favored.