Several reasons. If there is a blockage in an artery supplying the heart, pain will occur, often on exertion but it could occur at rest as well. Pericarditis, an inflammation in the sac around the heart, can also cause pain. But remember, not all pain in the chest is related to the heart. Pain related to GI problems, for instance, can simulate heart pain.
Angina. Which is caused by coronary artery blockages and pericarditis.