foursquare was co-founded by Dennis Crowley and Naveen selvadurai in 2007. They worked in the same office building together and decided to create a great app that helped people find great things around them that they wouldn't normally see.
Working from Dennis' kitchen table in New York's East Village, the first version of foursquare was completed in the fall of 2008. Their official launch was was at the South by Southwest interactive conference in Austin, Texas in March 2009.
A walkthrough of the history behind the app can be read here.