All pickups have some articulation between the cab and the bed. It's hard to make a frame that's that solid that doesn't add a lot more weight. The rubber strip's primary purpose, according to the manufacturers, is to make the gap more aerodynamic. As air flows past the side (and the bottom) of the truck, it tends to blast in through the space in front of the bed, and out the top behind the cab. This, combined with the turbulence generated, creates drag. Putting the rubber "dam" or "seal" inside there (I hesitate to say seal because it's not really a tight seal) causes that air flow to slow down, almost stop. Damming that gap up doesn't completely get rid of the turbulence or the air flow behind the cab, but it cuts the vast majority of it out and reduces drag a little bit.
I suspect the reason that the rubber doesn't quite touch the cab is because if it did, it would drag fine grit across the cab's paint job. So leaving a small gap makes a lot of sense.
I cannot claim that this is exactly the reason it's this way, all I have is my memories of discussions from dealers and literature in the past.