In Spinning Up by OpenAI, it says the following regarding policy optimization methods and Q-Learning as ways of getting a good policy for RL.
Trade-offs Between Policy Optimization and Q-Learning. The primary strength of policy optimization methods is that they are principled, in the sense that you directly optimize for the thing you want. This tends to make them stable and reliable. By contrast, Q-learning methods only indirectly optimize for agent performance, by training $Q_{\theta}$ to satisfy a self-consistency equation. There are many failure modes for this kind of learning, so it tends to be less stable. But, Q-learning methods gain the advantage of being substantially more sample efficient when they do work, because they can reuse data more effectively than policy optimization techniques.
What I am wondering is the motivation behind Q-Learning in this sense; I understand that when it works, it can be nice getting better sample efficiency, but what I don't understand is why Q-Learning was even considered in the first place as a way to approximate the optimal policy. It seems counterintuitive to me to have something I want to optimize and then to not optimize it, but rather optimize something else.
In other words, why does Q-learning work when it does?