The Federal National Mortgage Association (FNMA), commonly known as Fannie Mae, [was] founded in 1938 during the Great Depression. [It’s] purpose is to purchase and securitize mortgages in order to ensure that funds are consistently available to the institutions that lend money to home buyers. From Wikipedia.org
Freddie Mac is more formally known as The Federal Home Loan Mortgage Corporation. It's also a GSE and it's job is to buy mortgages on the secondary market, pool them, and sell them as mortgage-backed securities to investors on the open market. (excerpted from Wikipedia here)
The Government National Mortgage Association (GNMA, also known as Ginnie Mae) is a U.S. government-owned corporation within the Department of Housing and Urban Development (HUD).
Ginnie Mae provides guarantees on mortgage-backed securities (MBS) backed by federally insured or guaranteed loans, mainly loans issued by the Federal Housing Administration, Department of Veterans Affairs, Rural Housing Service, and Office of Public and Indian Housing. Ginnie Mae securities are the only MBS that are guaranteed by the United States government. (shamelessly lifted wholesale from Wikipedia - here - because they do such a darn good job and I can't re-write it better than they did)
Fannie and Freddie had some troubles in the early- and mid-2000’s which began in the 1990’s (some say the 1970’s), continued through 2004 and ultimately resulted in the federal government taking over the two mortgage giants in late 2008. Wikipedia does an excellent job of rehashing Fannie's history in four or five short paragraphs subtitled “Contributing Factors and Early Warnings”.