Understanding the proof that A* search is optimal
The key phrase here is


  because heuristics are admissible


In other words, the heuristics never overestimate the path length:

$$cost(n) + heuristic(n) \le cost(\text{any path going through n})$$

And since the frontier is ordered by $\textbf{cost + heuristic}$, when a completed path $p$ is dequeued from the frontier, we know that it must necessarily be $\le$ any path going through some other frontier node $q$, because

$$cost(p) = cost(p) + heuristic(p) \le cost(q) + heuristic(q) \le cost(\text{any path going through q})$$