The answer could also be that it's just enjoyable.
"First and foremost, they like it! Simple as that," Kelly Moffat, a veterinary behaviorist and medical director of the VCA Mesa Animal Hospital, told VetStreet. "Putting their head[s] out the window gets them closer to all the exciting happenings outside of the car."
Not to ruin the fun, but there are some potential dangers involved when a dog has his head out the car window. Keeping the window halfway up will prevent your dog from jumping out, but will still allow him to smell all the smells.
It's also probably safest not to let your dog stick his head out the window on the freeway. Wind gusts at high speeds can cause damage to a dog's eyes and eardrums, especially if he gets hit with something like a pebble or rock.