We present deep images of dust continuum emission at 450, 800, and 850 mum of the dark cloud LDN 1689N, which harbors the low-mass young stellar objects (YSOs) IRAS 16293-2422 A and B (I16293A and I16293B) and the cold prestellar object I16293E. Toward the positions of I16293A and I16293E we also obtained spectra of CO-isotopomers and deep submillimeter observations of chemically related molecules with high critical densities (HCO+, (HCO+)-C-13, DCO+, H2O, HDO, and H2D+). Toward I16293A we report the detection of the HDO 1(01)-0(00) and H2O 1(10-)1(01) ground-state transitions as broad self-reversed emission profiles with narrow absorption and a tentative detection of H2D+ 1(10)-1(11). Toward I16293E we detect weak emission of subthermally excited HDO 1(01)-0(00). Based on this set of submillimeter continuum and line data, we model the envelopes around I16293A and I16293E. The density and velocity structure of I16293A is fitted by an inside-out collapse model, yielding a sound speed of a 0: 7 kms(-1), an age of t = (0.6-2.5) x 10(4) yr, and amass of 6.1 M.. The density in the envelope of I16293E is fitted by a radial power law with index -1.0 +/- 0.2, a mass of 4.4 M., and a constant temperature of 16 K. These respective models are used to study the chemistry of the envelopes of these pre- and protostellar objects. We made a large, fully sampled CO J = 2-1 map of LDN 1689N, which clearly shows the two outflows from I16293A and I16293B and the interaction of one of the flows with I16293E. An outflow from I16293E reported elsewhere is not confirmed. Instead, we find that the motions around I16293E identified from small maps are part of a larger scale fossil flow from I16293B. Modeling of the I16293A outflow shows that the broad HDO, water ground state, and CO J = 6-5 and 7-6 emission lines originate in this flow, while the HDO and H2O line cores originate in the envelope. The narrow absorption feature in the ground-state water lines is due to cold gas in the outer envelope. The derived H2O abundance is 3 x 10(-9) in the cold regions of the envelope of I16293A (T-kin <14 K), 2 x 10(-7) in warmer regions of the envelope (> 14 K), and 10(-8) in the outflow. The HDO abundance is constant at a few times 10(-10) throughout the envelopes of I16293A and I16293E. Because the derived H2O and HDO abundances in the two objects can be understood through shock chemistry in the outflow and ion-molecule chemistry in the envelopes, we argue that both objects are related in chemical evolution. The [HDO]/[H2O] abundance ratio in the warm inner envelope of I16293A of a few times 10(-4) is comparable to that measured in comets. This supports the idea that the [HDO]/[ H2O] ratio is determined in the cold prestellar core phase and conserved throughout the formation process of low-mass stars and planets.