As the railway developed and expanded one of the key issues was the gauge (rail separation) of track to be used. This eventually resulted in the adoption of a standard gauge to allow inter-connectivity and inter-operability of the trains.
In the UK this gauge was at first 4 feet eight inches but later widened slightly to four feet eight and a half inches. Rail systems in the United States eventually adopted a similar gauge; however, many early US trains were purchased from the UK so well into the 1800s the USA had several different gauges of track.
There is no good reason for this particular gauge to have become the standard, other than perhaps it was more widespread than any other.
A poular Urban legend traces it even further to rutted roads dating back to the Roman Empire. See the Snopes web page (be sure to read the whole thing -- they have a lengthy quote up front which seems to support the Roman idea) for a very thorough historical discussion of the whole issue.