Good question. It is a US tradition and I'd guess it is 18th century. It arises because sons are named exactly after their fathers. The earliest example I could find was John Jacob Astor, Jr (1791 - 1869) who was the son of John Jacob Astor (1763 - 1848)
According to this etymology dictionary, junior (Jr.) was from the 1630s, and senior (as the father of two men with the same name) from the 13th century.