Going all out, with maximum effort, similar to the automotive ‘pedal to the metal.’
The phrase is first found in military aviation. In many planes, a control stick may be topped with a ball-shaped grip. A throttle on an early aircraft had such a ball on the end of it. In order to go full throttle, the pilot had to push the throttle all the way forward against the firewall (so-called because it prevents an engine fire from reaching the rest of the plane). Therefore, ‘balls to the wall’ meant going very fast.
Another control is the joystick. Pushing that forward sends a plane into a dive. So, literally pushing the balls to the (fire)wall would put a plane into a maximum-speed dive.
The earliest written citation is from 1967, appearing in Frank Harvey’s Air War—Vietnam.
It was recorded in the slang of U.S. Air Force Academy cadets in 1969. Korean War veterans have also claimed that they used the expression in the 1950s.
An earlier parallel phrase is ‘balls-out,’ in the same sense, which is found in military-aviation sources that date from World War II. The phrase was one of those painted on the nose of fighter planes.
One theory is that the phrase arose in railroad work. A speed governor on train engines had round, metal weights at the end of arms. As the speed increased, the spinning balls would rise and become perpendicular to the walls at maximum speed. But there is no evidence to support that theory.
It’s a fun phrase to use, and is now applied to many personal and professional life situations. A team of paramedics might respond to an accident scene in a ‘balls to the wall’ way, or an athlete might train in a manner considered ‘balls to the wall.’
As for why the phrase is fun to say, there are two reasons. For one, it has ‘consonance.’ According to Wikipedia, consonance is a literary device identified by the repetition of consonant sounds at any point in a word (for example, hot foot). It’s like alliteration, which is a special case of consonance where the repeated consonant sound is usually at the beginning of the words. And then there’s the reference to the male anatomy to give it a little spice.