Hard water works against good lather, and very hard water can make lather almost impossible. The ideal solution (for shaving, doing laundry, showering, doing dishes, and so on) is to buy a good water softener (that recycles based on volume of water used and not on time) and plumb it so that all the water in the house goes through the water softener except for the kitchen cold-water tap. By having all water soft, the pipes will say clear, the taps will operate better, and hard water deposits will be a thing of the past.
But installing a water softener is not cheap, and if you live in an apartment, it may be impractical. A good fallback is to buy “purified” water at the drugstore (essentially distilled water), which costs about $1/gallon and is sold for use in humidifiers and steam irons and the like. Then get something to heat it with—and my recommendation is the Adagio UtiliTEA electric kettle, which will heat water to the temperature you specify: from a full roiling boil down to moderately warm. You will have to experiment a little to locate the setting that brings the water to the ideal temperature for shaving, but then you have hot water that will produce a flawless lather and will rinse razor and face with no traces of soap scum.