It remains an unsolved mystery what possessed men to wear such short shorts during the '60s through the '80s, so let's take a crack at it. I'm focusing on men because it was a much more extreme departure from the norm, and because it didn't have to do with trying to look sexy. So it requires a more thoughtful answer.
From the timing of its rise and fall, it looks like it's tied to the trend in the violent crime rate and all the other things that are associated with it as well. But which ones? I think it's trust, but let's look at the pattern of its rise and fall first.
Unfortunately the climate was much colder during earlier major waves of violence, so we can't go back that far to examine the possible link. Men didn't wear any kind of shorts in the Elizabethan-Jacobean or Romantic-Gothic waves because they were still in the Little Ice Age. So we'll look just at the 1950s through today.
Men's shorts were knee-length in the '50s:
Even though that was a time of falling crime, the first hint of short shorts began around 1956, and a year or so later there had been several pop songs referring to them. ("Who wears short shorts? We wear short shorts!") Although they were talking about girls wearing them, there's usually a close fit between male and female fashions for how much skin is shown. So men were probably wearing somewhat shorter shorts by the mid-late 1950s as well. Because the crime rate doesn't start rising until 1959, it looks like shorter shorts slightly precede the crime wave. I don't mean they existed at all, but that they were widespread, unlike say the Beatniks who also prefigured some of the '60s culture but were totally marginal in the '50s.
Of course short shorts only exploded in popularity during the '60s, '70s, and '80s:
When did they vanish? I looked at a class picture from spring 1990, and both boys and girls are still wearing fairly short shorts, though not quite as bare as dolphin shorts. However, the class picture from 1992 shows almost everyone with shorts that hit the top of the knee, boys and girls both. That was elementary school, but here are what the teenagers were wearing in the early '90s:
Because the crime rate peaks in 1992, it looks like they had already been in sharp decline for several years before falling-crime times began to set in.
Shorts only got longer and baggier throughout the '90s, and by the 2000s every guy was wearing some version of cargo shorts, baggy jean shorts, or even the occasional closeted faggot who wore capri pants. (These were re-named "man-pri" pants in yet another case of emasculated behavior being labeled "man ___" in a poor attempt to conceal its blatant homosexuality.)
The only thing I've seen that overlaps the crime rate trends, but beginning to move up or down slightly before the crime rate does, is trust levels. That would seem to be what guys' wearing short shorts is about then. It's not about their more promiscuous mating strategy during rising-crime times, because that would've gotten started only in the '60s and lasted through the early '90s. Plus girls don't care what your legs look like anyway; to the extent that they do look you over, it's your face, upper body, and butt.
Trust levels go hand-in-hand with cocooning: low trust is just the description at the psychological level, while cocooning describes the actual behavior. So I see wearing short shorts as part of the larger trend toward leaving your own isolated cell in the hive, putting yourself out there, letting your guard down, and trusting others not to put you down or take advantage of you. You've already left your house, but why not also remove some of the remaining physical barriers between you and the outside world -- like clothing? I don't think it's a "return to nature" thing, or a generalized "lose your inhibitions" thing, since those were not underway by the mid-late '50s.
When trust levels peaked in the late '80s, that's about when shorts started getting longer, probably because people had already begun to retreat from public exposure and into their own little worlds again. From the '90s through today, we've come to trust others so little that we don't feel comfortable putting ourselves out there, even in admittedly trivial ways like wearing shorter shorts.
There's something related going on with clothes that are closer to the body vs. more tent-like, again just another aspect of wanting to hide yourself and keep people farther away in public vs. being more carefree because you trust them. I'll write that up another time, but women's dresses became more column-like and less poofy during the Early Modern and Romantic-Gothic waves of violence, also during the Jazz Age, and then skin-tight during the New Wave Age. They bloated out, hiding any hint of her actual figure, during the mid-1500s, the Age of Reason, and the Victorian era, all periods of falling crime. During the mid-20th C and the past 20 years, they haven't returned to quite that degree of circus tent concealment, but they still weren't as clingy as they were in the Jazz Age or New Wave Age.
There are two main camps regarding how fashion responds to larger social trends: one says they aren't related to anything else, and the other that they're related to material subsistence or economic health. Both are wrong. Some fashion trends really do look unconnected to other trends, but a good deal is tracking the trend in the violence rate. I've got more quantitative data going back to the late 1700s, but for now it's probably better to stick with some case studies that are richer in detail so you get a good sense of just how cyclical fashions can be, and in particular matching the cycles in the violence rate.