What is the usage of a decision problem for an optimization problem like the longest path problem?
In complexity theory, we tend to focus on decision problems. They're conceptually simpler and the corresponding function and optimization problems can be reduced to them with only a polynomial loss of efficiency. From a theoretical point of view, polynomial factors are considered "efficient".

Let's take your example of Longest Path.  We know that the longest path has length between 1 and&nbsp;$n$ (where $n$&nbsp;is the number of vertices), so we can find the actual length of the longest path by doing binary search using a series of queries of the form "Is there a path of length at least $n/2$?", "... $3n/4$?", ... That tells us that the longest path has some length&nbsp;$\ell$.  Now, we can loop through the edges one by one.  Delete the $i$th edge and ask, "Is there still a path of length at least&nbsp;$\ell$?" If there is, go on to the next edge; if there isn't, undelete edge&nbsp;$i$ and go on to the next one.  When this algorithm terminates, we'll be left with a graph that is exactly a path of length&nbsp;$\ell$. We used $\Theta(\log n$) calls to Longest Path to find the length of the longest path, and $O(n^2)$ calls to find the actual path.

The decision problem isn't necessarily "useful" per se: as you observe, the function problem ("Give me a solution", rather than "Is there a solution?") is the one we usually want to solve, practically speaking.