The scope and content of the prior art are to be determined.
Differences between the prior art and the claims at issue are to be ascertained.
And the level of ordinary skill in the pertinent art is to be resolved.
Such secondary consideration as commercial success, long felt but unsolved needs, failure of others, etc., might be utilized to give light to the circumstances surrounding the origin of the subject matter sought to be patented.
I.e., if previous attempts failed, unsolved needs took forever, etc. then the solution apparently was not obvious.
If the solution to a problem would be obvious if the problem were to be considered, the solution is usually going to be considered obvious. The non-obviousness of the problem itself does not provide protection.