Is this rule even true and why is it? I'm going to assume it has to do with pressure but can someone give me a good explanation?
Yes It's true. And yes it's related to pressure.
Have you heard of "The bends" or decompression sickness?
As divers go deeper the pressure increases. The longer you dive and deeper you go the more nitrogen is absorbed into your blood as a dissolved gas. As you return to the surface the pressure reduces and the nitrogen reverts to a gas.
This decompression needs to be done slowly so the nitrogen can pass back out through your lungs. If you ascend too fast the nitrogen can form bubbles in your blood (Just like when you open a bottle of coke.) which can be painful and possibly fatal.
Even once you have finished diving you will still have residual nitrogen in your blood which will take time to release.
Air pressure reduces further when you fly. If you finished a dive and got in a plane the rapid climb in altitude would result in a drop in pressure similar to a rapid ascent while diving. So you would run the risk of getting the bends.
Small planes aren't pressurized. But even pressurized planes might not maintain atmospheric pressure when flying.
This topic should have been covered if you have taken a dive course.
To add a reference to Peter's answer, from PADI, one of the institutions that releases Scuba diving certificates:
Flying after Diving Recommendations
For Dives within the No-Decompression Limits
Single Dives: A minimum preflight surface interval of 12 hours is suggested.
Repetitive Dives and/or Multi-Day Dives: A minimum preflight surface interval of 18 hours is suggested.
For Dives requiring decompression stops:
A minimum preflight surface interval of greater than 18 hours is suggested.
It's not just blood, but soft tissue generally.
48 hours is extremely conservative - recreational (single tank of air, 40metre maximum depth) diving guidelines say only 24 hours.
Don't forget altitude (lakes at > 300metres) diving also affects No-Decompression Limits.
When diving, your body absorbs nitrogen gas. As you ascend towards the surface, your body releases that gas. If it is released too quickly, you'll get "The Bends".
Modern dive computers model the body as a series of different tissues: fat, muscle, liver, cartilage, brain/nerves, bone marrow, etc. Different dive computers will model different tissues, typically between 8 and 20 tissues.
Each of these tissues absorbs, retains, and releases nitrogen at different rates. The dive computer will track a number of different tissues, but show you only the most critical of the tissues (eg, the one that will take the longest to off-gas to a safe level). Depending on how long you've spent at various depths, the critical tissue will change. This is guidance for just returning to the surface safely.
Other factors affect each individuals off-gassing rates, such as BMI, general health, specific metabolism, and alcohol consumption.
When you later fly, you're going to even less pressure, and your tissues will off-gas even more. If you're flying in a typical pressurized commercial jet, you'll be at around 8,000 ft pressure-altitude. But if you're in an un-pressurized charter flight, you could easily hit 10,000 - 16,000 feet. Many people have trouble understanding that a "small" plane will actually hit a higher pressure-altitude at 14,000 feet, than a "big" jet at 30,000 feet.
If you haven't been doing extreme diving, and are flying pressurized, then 24 hours is safe for a normally healthy person. If you're flying un-pressurized above 10,000ft, then 24 hours may be safe. But because The Bends depends on many subtle factors and is unpredictable, 48 hours is considered much safer.
This leads to the typical dive planning advice that you should begin with your most aggressive (deepest, longest) dives first, and use your easier dives later in the trip. Your body can continue to off-gas from your most deepest dive even during your subsequent, shallower dives. This is a little contrary to human nature, as many people want to begin at an easier level, and get more aggressive with each dive as their comfort level grows. But that only sets up the body for a high N2 load, adding more and more with each dive.
If you have any aggravating factors, such as poor health, significant fat (BMI), alcohol consumption, or a prior incident with decompression, then I would avoid the more aggressive dives and plan on as much time as practical before even a pressurized flight. For many recreational divers, this simply translates to "no diving and no drinking on the last day of a trip: Just go sightseeing, or stay on the beach"
Credentials: Certified NAUI, PADI, and SSI; Trained Recuse Diver; Experienced with Deep, Night, Dry Suit. (but mostly retired and above the surface now).
By every recommendation I've ever seen 48hrs is extremely liberal for recreational divers. I went on my first dive trip with my parents when I was 12 years old and our rule was to quit diving at least 24 hours before your flight. It is related to pressure and it all depends on how much time you've spent and at what depth. The deeper you go, the quicker you build nitrogen in your tissues and the more time you'll need to allow for that nitrogen to dissipate. If you spend enough time at depth there is even a recommendation to make a safety-stop during your dive (typically 5-15 minutes at about 30ft for recreational diving) as a best-effort to avoid the bends and surface decompression. The U.S. Navy created classification charts that indicate your relative nitrogen absorption. Here are some resources hosted by NOAA, one of them being a PDF specifically covering this topic.