It wasn't so much that retailers weren't allowed to sell such records to minors, it was more because they elected not to stock said records for fear of boycotts by conservative groups. There were never any laws (at least not at the federal or state level) restricting the sale of explicit music to minors; in fact the whole reason the RIAA adopted the Parental Advisory logo (it started as a sticker, but was later incorporated into the album covers themselves) was to prevent Congress from passing such laws.
Here's the Senate hearing that started it all: https://www.youtube.com/watch?v=d65BxvSNa2o
I should probably also note that edited "clean" versions have another function: radio airplay. The Federal Communications Commission (FCC; the US government body that regulates television and radio transmissions) has rules about what words and content can and cannot be broadcast on radio/television, so record companies often create edited versions in order to get the songs played on air.