In baseball, an earned run is any run that was fully enabled by the offensive team's production in the face of competent play from the defensive team. Conversely, an unearned run is a run that would not have been scored without the aid of an error or a passed ball committed by the defense.
An unearned run counts just as much as any other run for the purpose of determining the score of the game. However, it is "unearned" in that it was, in a sense, "given away" by the defensive team.
Both total runs and earned runs are tabulated as part of a pitcher's statistics. However, earned runs are specially denoted because of their use in calculating a pitcher's earned run average (ERA), the number of earned runs allowed by the pitcher per nine innings pitched (i.e., averaged over a regulation game). Thus, in effect, the pitcher is held personally accountable for earned runs, while the responsibility for unearned runs is shared with the rest of the team.
To determine whether a run is earned, the official scorer must reconstruct the inning as it would have occurred without errors or passed balls.