Let's take a look at history and look at the faces on Mt Rushmore:
George Washington - 1st President; average POTUS Rating #2
Lt Col, Virginia Militia - French & Indian War. Mentioned in dispatches for gallantry in combat, revered by his American troops, respected by British officers.
General of the Armies of the United States (O-13, 1976), Commanding General of the Continental Army (1775), Commanding General of the United States Army (1794, 1797) Military experience mattered.
Teddy Roosevelt -26th President, average POTUS Rating #6
Lt Col, Army of the United States (Volunteers) - Spanish American War.
MEDAL OF HONOR
Military experience mattered.
Thomas Jefferson - 3rd President, average POTUS Rating #7
Captain, Virginia Militia but never activated.
No real military experience, however a very good president.
Abraham Lincoln - 16th President, average POTUS Rating #1
Captain, Illinois Militia - Black Hawk War. Noticed for gallantry.
Military experience mattered.
OTHER NOTABLE CONTENDERS
FDR - 33rd President, average POTUS Rating #3
Secretary of the Navy but no military service contracted polio and could not serve.
An excellent president who served with military troops.
Ike - 35th President, average POTUS Rating #4
General of the Army (O-11), Supreme Commander Allied Forces Europe. Lead Operation Torch, the seaborne invasion of North Africa, five months later the enemy had been evicted from more than 4000 miles of territory. Conducted operations in Italy which led to the eventual collapse of one of the Axis powers. Oversaw the D-Day Invasion in France. Within two months Paris was liberated. Less than 300 days after that the war in Europe ended with complete victory.
An excellent president, military experience mattered.
Truman - 34th President, average POTUS Rating #5
Captain, US Army, World War One Western Front, Artillery.
An excellent president, military experience mattered.
Ronald Reagan - 40th President, average POTUS Rating #6
Captain, US Army WWII.
Already a movie star he didn't serve in combat he talked on the radio.
So military service didn't really make a difference.
Ulyseus S Grant - 18th President, average POTUS Rating #8
General of the Army (O-10), Commanding General of Union Forces. Victorious in 15 battles. Destroyed the Army of Northern Virginia (CSA) and accepted Lee's surrender effectively ending the Civil War.
An excellent president, military experience made the difference.
So most would agree that military or government service probably matters. Now lets take a look at the other end of the list:
Warren G Harding: 5th Worst President.
No military experience but an excellent crook who never got caught.
Richard Nixon: 4th Worst POTUS
No military experience and he got caught. A couple of times actually.
Franklin Pierce: 3rd Worst
Captain: Mexican American War. His horse reared and the pommel of his saddle crushed his groin knocking him out. He was a real coward in office too.
His military experience taught him how to run away. Not exactly inspiring.
James Buchanan: 2nd Worst
No military experience but he liked getting the shaft up his butt. Incompetence was his watch word.
Don da con Adolph J Trump aka Hitler: Worst... ALL Time.
No military experience but he was a great liar and he almost started the Second American Civil War. Fed the American people a load of balongy for 40 years and 70 million fools still believe it. Still lying, but he can claim to fame: The only POTUS to be impeached twice.