Top of the first, nobody out. The leadoff hitter pushes a hit through the left side. The left fielder bobbles the ball, and allows the batter to advance to second. This is scored as a single and an error. (Any fielding mishap which allows a runner to advance an additional base is scored as an error, if I’m not mistaken.)
Now. The second batter up strokes a single of their own into center field. The leadoff hitter scores from second on the hit. The next three men are retired in order.
Depends on how the other three guys were retired. If they all struck out, then it would be an unearned run because you would only have runners on first and third without the error.
However, if the next three batters hit into fly outs or ground outs, the scorer might rule that the runner would have scored anyway.
The pitcher does get the benefit of the doubt in this situation.
You have to figure out the earned and unearned runs at the end of each inning. You have to recreate what would have happened in the inning had their been no errors or passed balls.
In the OP, we don’t have enough info to figure out what would would have happened. Just because the runner is in scoring position doesn’t mean he would have scored.