Change to a gear where your effort/speed ratio makes you happy at your preferred cadence. This is ultimately the answer. What does that mean? First let's prioritize the statement.
"Makes you happy." This is the most important part of the statement. If you aren't happy, you are doing it wrong.
"Preferred Cadence." This means how many times you turn the pedals in a complete circle each minute. For most regular cyclists this is somewhere in the 85-95 range, but many recreational cyclists are more around 70 rpm.
If you are in a tall gear (the big ring on the front and little rings on the back) one rotation of the cranks will spin the rear wheel multiple times based on the ratio of gears. So if the big ring is a 48 in front, and the small gear is 11 in back, then every turn of the crank will turn the wheel 4.36 times (calculated as 48/11). On a 700-25 tire. If your cadence is 80, then every minute, your rear tire spins 349 times around and you travel about .45 miles(2100mm*349 <convert to miles>) at 27.3 mph (.45mi*60 min). If the small ring is 28 and the large ring is 32, these become .875 revolutions per crank * 80 rpm = 70 tire rotations, .091 miles at ~5.5 mph. Depending on the external forces acting on the bike, these two may require the same effort, more or less. Effort is the product of road surface, wind, elevation and a bunch of other factors. Just to be clear, you do not need to do math for this to work, that's just to illustrate what's happening with the gears.
Now, when you start riding up the hill, try and keep your cadence going. When it becomes too hard, change gears to a larger ring in the back or a smaller ring in the front. Continue this process until you find a combo where you are comfortable with your effort level. It sounds like you probably need to drop to a smaller sized ring in the back since you are spinning a lot and feeling like you aren't moving. Add back gearing in the rear in progression until you find an effort level that makes you happy. This will change from day to day and even from morning to evening.
I will now reiterate that the most important part of this process is "Makes you happy."
Enjoy the ride!