From Openwaterpediaswimwear. They were originally developed for aquatic sports, specifically for surfing, but in more recent years they have grown in popularity outside of these sports, and have become a popular form of general beach and summer wear.
The name of "boardshorts" originates from their affiliation with aquatic sports that use a board, such as surfing. They are sometimes called "boardies" in slang, especially in Australia, and "baggies" in South Africa.
Boardshorts are especially popular in North America, much more so than Speedos on the beach, and have spread beyond surfing especially as the skater punk fashion trend got underway. They are also typically worn in men's beach volleyball.