Original: The lyrics come from "Defence of Fort McHenry", a poem written in 1814 by the 35-year-old amateur poet Francis Scott Key after witnessing the bombardment of Fort McHenry by Royal Navy ships in Chesapeake Bay during the Battle of Baltimore in the War of 1812.
Simplified: Francis Scott Key wrote the words to it in 1814 after seeing British ships attacking Fort McHenry in Baltimore, Maryland during the War of 1812.