It was a compromise created during the Constitutional Convention which moved the capital closer to the southern states so they could be better represented and in return, the Federal government would assume the state debt from the Revolutionary War.
To create Washington DC, both Virginia and Maryland had to cede land to provide the space for the capital city to be created. The city sits between the Potomac and Anacostia Rivers and was created to showcase the capital at its center. George Washington was given the duty to choose the exact spot for the new capital city and oversaw the construction of the capital.