It basically dates back to later 19th century fencing practices at French military academies. They would drill many soldiers at once, which required a limited space. Initially, they trained outside, and to combat the uneven surface created by repeated bouts, they began using a planche, literally a board, approximately 5 meters by 0.5 meters.
This was later superseded by joined boards, but kept approximately the same dimensions:
When they began moving the fencing into indoor salles, they kept the planche arrangement.
As to why the piste expanded past the size of the planche to its current dimensions, as best I can tell, it happened around 1922 as a result of it being lengthened to allow more spectators, and widened to account for it be raised for easier viewing by the crowds and to make the bout more dynamic.