The function is measurable and 0≤cos2(1/x)≤1. Since (0,1) has finite Lebesgue measure, comparison gives ∫01g≤1. Therefore g is integrable on (0,1), despite oscillating infinitely often near zero.
For x>1, 1/x∈(0,1) and cos2(1/x)≥cos2(1)>0. Its integral over the infinite interval is bounded below by the integral of a positive constant. Therefore g is not integrable on (1,∞). In fact it tends to one at infinity.