Old English up, uppe, from Proto-Germanic *upp- "up" (source also of Old Frisian, Old Saxon up "up, upward," Old Norse upp; Danish, Dutch op; Old High German uf, German auf "up"; Gothic iup "up, upward," uf "on, upon, under;" Old High German oba, German ob "over, above, on, upon"), from PIE root *upo "under," also "up from under," hence also "over."
As a preposition, "to a higher place" from c. 1500; also "along, through" (1510s), "toward" (1590s). Often used elliptically for go up, come up, rise up, etc. Up the river "in jail" first recorded 1891, originally in reference to Sing Sing, which is up the Hudson from New York City. To drive someone up the wall (1951) is from the notion of the behavior of lunatics or caged animals. Insulting retort up yours (scil. ass) is attested by late 19c.
river n.
early 13c. (late 12c. in surnames), "a considerable body of water flowing with perceptible current in a definite course or channel," from Anglo-French rivere, Old French riviere "river, riverside, river bank" (12c.), from Vulgar Latin *riparia "riverbank, seashore, river" (source also of Spanish ribera, Italian riviera), noun use of fem. of Latin riparius "of a riverbank" (see riparian).
The generalized sense of "a copious flow" of anything is from late 14c., as is figurative use. The Old English word was ea "river," cognate with Gothic ahwa, Latin aqua (see aqua-). Romanic cognate words tend to retain the sense "river bank" as the main one, or else the secondary Latin sense "coast of the sea" (compare Riviera). In printing by 1898: "streaks of white space in text caused by the spaces between words in several lines happening to fall one almost below the other."
U.S. slang phrase up the river "in prison" (1891) is said to be originally in reference to Sing Sing prison, up the Hudson River from New York City. The phrase down the river "done for, finished" (1893) perhaps echoes the sense in sell down the river (1836, American English), originally of slaves sold from the Upper South to the harsher plantations of the Deep South.