From The Londonist:
The Royal Navy fought the combined forces of the French and Spanish at The Battle of Trafalgar on 21 October 1805. Admiral Lord Nelson was on HMS Victory and although the British won the battle he famously died in action, elevating him to hero status.
Why this Location?
The land was part of the Great Royal Mews and used as stables by Whitehall Palace from the 14th to the late-17th century.
After beginning his reign following the Regency Act in 1811 (while his father, King George III, was “mad”), The Prince Regent wanted to make his mark on London. He instructed John Nash to plan a street from Charing Cross to Portland Place with an open public square at Charing Cross. Regent Street was completed in 1825 and the area for the public square was cleared in 1829 as part of the Charing Cross Improvement Scheme. By 1830, the square was officially named Trafalgar Square.
Work on locating the National Gallery along the north side of the square began in 1832 and was completed in 1838. Designed by the architect William Wilkins, he also submitted plans for the whole square, but died in 1839 so new plans by Sir Charles Barry (architect of the Palace of Westminster) were approved quickly.