Apparently,the hill climbing algorithm just produces a local maximum,and not necessarily a global optimum.It's stuck on a local maximum.Why does hill climbing algorithm only produce a local maximum?

This part of your sentence is not always true "and not reached to final goal/solution".If you have just one maximum at all and it is finite,hill climbing (HL) can reach to it and it is a global maximum too (for example,if the function is a parabola).

To answer your question is back to the stop criteria of HL.It will be stopped when reaching to a maximum point.The maximum point means a point which the objective function has a greater value in that point than on its$\epsilon$-neighborhood of that point.Therefore,if objective function has some local maxima,depends on the initial point of HL,it might be trapped in one of the local maxima as their definition is satisfied in the explained definition.

In sum,depends on the initial point of HL,it might not reach to the global maxima and trapped in local maxima if there exists.