The law is
(a) A patent may not be obtained though the invention is not identically disclosed or described as set forth in section 102, if the differences between the subject matter sought to be patented and the prior art are such that the subject matter as a whole would have been obvious at the time the invention was made to a person having ordinary skill in the art to which said subject matter pertains. Patentability shall not be negatived by the manner in which the invention was made.
Unfortunately, in practice, I think it has often been subjectively determined. It is not, or should not be, “seems obvious to me”. Hindsight bias is a strong force. Once you know something it is almost impossible to put yourself in the shoes of someone who does not know it. Non-obviousness does not actually require a great improvement in a product nor does it require a flash of genius (at least since the laws were changed in the early 1950s). The requirement for nonobvious was not put in place to eliminate non-brilliant inventions it was to acknowledge that something might technically be novel but only be an “obvious” step beyond what had been already done.
Until a few famous SCOTUS cases ago there were safeguards against hindsight bias in place. An examiner needed to find references that, collectively, contained all of the elements in a claim, as is still the case. Then they had to find something in the prior art record that showed that, before the filing date, there was a public record of a teaching, suggestion or motivation to make the combination - the TSM test. The TSM test was said to exclude the examiner or judge from using “common sense” in the KSR case.
In that SCOTUS case TSM was downgraded to a “nice to have” and common sense is allowed to be used in filling in missing pieces in an obviousness argument, at least by judges.
This is KRS v Teleflex https://en.m.wikipedia.org/wiki/KSR_International_Co._v._Teleflex_Inc. and this article explains the revolutionary effect of two cases from the early 2000s. https://www.msk.com/newsroom-alerts-2514