Short version, from what I remember...
After the 1986 Miami Shootout, the FBI wanted a more potent round. They ended up going with a 10mm "lite" load, 180gr JHP @ 950fps. Being 10mm, though, the resulting gun was rather large. I can't remember if it was in response to this, or if it was happening around the same time, but S&W and Winchester partnered up to create a round with the same ballistics, but could fit in 9mm-sized guns for higher capacity and easier carry/concealment than the big 10mm guns. .40S&W was born.
I've probably glossed over some details, but I think this is the gist of the story. Hopefully, someone will come along and correct any errors.