Earned and unearned runs count equally toward the game score; the difference is purely statistical.
To determine whether a run is earned, the official scorer must reconstruct the inning as it would have occurred without errors or passed balls.
If no errors and no passed balls occur during the inning, all runs scored are automatically earned (assigned responsible to the pitcher(s) who allowed each runner to reach base).
The runner who reached on the error comes around to score, and his run is unearned to both the prior pitcher and the team.
However, the run scored by the batter is counted as earned against the relief pitcher, but unearned to the team (since there should have already been three outs).
The batters he put on base may be erased by fielder's choice plays after he has been relieved by another pitcher, but if earned runs are scored in the inning the original pitcher is liable for as many earned runs as the number of batters he put on base.