Plasma heating by relativistic electron beams. I. Two-stream instability