Trim refers to a diver's orientation in the water: vertical (head up usually), diagonal, or horizontal (laying down / skydiver position). Proper trim for scuba diving for most situations is horizontal. Combined with neutral buoyancy, this key skill is a required standard taught in most introductory diving classes.
What is not always taught is the enormous benefits you get from proper trim. Here are some of the benefits:
Stable buoyancy and effortless depth control
Kicking while in a vertical or diagonal position will propel you upward or downward: whichever way your legs are pointed. Usually we want to maintain our depth in diving - not ascend or descend with each kick.
When in proper horizontal trim - your kicks propel you forward horizontally avoiding unwanted depth changes.
Horizontal trim positions your body for maximal drag in the vertical direction. This effectively slows your ascents and descents and helps you maintain your desired depth during your dive. Slow depth changes are good and help keep you safe and in control.
Horizontal trim spreads the air bubbles in your BC and (if applicable) drysuit throughout your body - helping to maintain stability. Moving into a diagonal head-up position will allow much of the gas in your BC and drysuit to migrate to your chest, arms, and shoulders (where it will also expand as it rises) - pulling you into an even more vertical position. The reverse is also true, moving into a head-down position will cause gas to migrate toward your feet in both your BC and drysuit - tending to throw you into an even more extreme head-down position. To minimize this effect, stay horizontal and carry just enough weight - so the air bubbles in your drysuit and BC are small (if overweighted, you will need more air in your BC and drysuit to compensate).
Easier, deeper breathing and more efficient gas exchange
When a diver is horizontal and facing forward (skydiver position - proper trim) on an open-circuit scuba regulator, their mouth and regulator are at about the same depth as their lungs. This means there is no signficant difference in the ambient pressure between the regulator, your windpipe, and your lungs. Gas is delivered at ambient pressure. This diver can easily breathe fully in and out, enabling efficient delivery of oxygen and preventing the harmful buildup of carbon dioxide.
Contrast that with an adult diver in a vertical (head-up) position. The regulator will be about 1 foot shallower than the center of their lungs. Ambient pressure increase by about 0.45 PSI per foot. So, the pressure on the lungs will be nearly half a pound per square inch (PSI) greater than the gas pressure delivered by the regulator to the diver's mouth. Given that the maximal inhalation (negative) pressure humans can generate when inhaling is only about 1 PSI - this pressure differential is huge! As a result, the effective lung volume of this vertical diver shrinks dramatically - they cannot breathe as deeply as a horizontal diver. Breathing also requires more energy.
You can experience the difficulty of breathing while vertical (divers in diagonal trim experience the same issue, just to a lesser degree) for yourself in a swimming pool. Standing in the shallow end, take some breaths while your lungs are completely above the water line. Repeat the exercise while in water up to your neck. Note how deeply you can inhale and how much effort it takes. You will notice it is more difficult to get a full breath while submerged.
Reduced risk of fluid in your lungs (immersion pulmonary edema, IPE)
The physical challenges of diving can cause fluid to leak into some divers' lungs. When this becomes serious enough to impact a diver's health it is called immersion pulmonary edema (IPE) and can result in a shortness of breath or an inability to breathe adequately even when your regulator is working fine. IPE is suspected as a primary or contributing cause a number of dive accidents and fatalities (also in other water sports such as triathlons).
Increased physical exertion and breathing against a negative pressure gradient (e.g. the situation when breathing in a head-up diagonal or vertical position) are both risk factors for IPE. See Castagna et al. Sports Medicine-Open 2018. "The Key Roles of Negative Pressure Breathing and Exercise in the Development of Interstitial Pulmonary Edema in Professional Male SCUBA Divers"
Reduced air consumption and effort
When you swim through the water horizontally in a horizontal trim position your are streamlined and present a small drag area in the direction of motion. This requires relatively little effort so you can maintain relaxed, normal breathing.
When you try to swim through the water horizontally while oriented diagonally or vertically - you present a large drag area in the direction of travel (like a kite catching the wind)- so it is very hard to move. Due to the enormous density of water (compared to air) your level of exertion will increase rapidly which, in turn, will cause you to breathe faster and increas your air consumption.
As discussed above, the work of breathing is higher when vertical or diagonal in the water because you must breathe against resistance to pull air delivered at your mouth to the deeper depth of your lungs - where the pressure is greater. Even if you do not move, you must breath faster to sustain this increased workload on your breathing muscles.
Divers who master proper (just enough) weighting and trim will find that they end their dives with more gas and less exhaustion.
Protect visibility and the environment
When you are in a heads-up vertical or diagonal position your fins point toward the ocean floor. Any kick from this position is likely to stir up silt and sand, and harm bottom-dwelling marine life.
Being in trim (and using a frog kick) protects you from silt outs (envision an underwater self-inflicted sandstorm) and protects organisms from unintentional harm.
Control and change your direction with ease
When you are diagonal or vertical it can be difficult to execute a proper turn (especially without losing control of your buoyancy).
When in proper horizontal trim, a gentle helicopter kick can quickly spin you to face in any direction - to turn a dive, admire a cool fish, or face a buddy to address a problem.