When I fill my electric water boiler with water some time before boiling it, the water gets warmer, it's temperature get closer to the room's temperature, saving some energy. On the other hand, I've heard that this decreases the lifetime of the boiler, especially with hard water. So which of these factors is more important? Or, if it depends, how can I determine if it's more eco-friendly to fill the boiler just before boiling or some time before?
Fill the boiler as long before you'll heat it as you can, assuming the ambient temperature is higher than the temperature of the incoming water. This will save energy. As you've pointed out in the comments: as it's going to be boiled, this will kill off any microbes.
It also gives you the option of pre-heating the water if very cheap, free, or negatively-priced energy becomes available: for example, if you've got a home PV system, or you're connnected to an electricity grid with high penetrations of exogenously-variable renewables (run-of-river hydro, solar, wind, tidal, wave). You may also be able to use it to sell ancillary (balancing) services to the grid.
Tackle the scaling from hard water either using occasional application of a descaler; or by putting an ion-exchange water-softener onto your water feed. As an added bonus, you'll also use less detergent. Though I don't know anything about the sustainability of the ion-exchange material that makes the softener work.
As the water is for drinking, there are a couple of things to bear in mind. If you use a water softener, then: some people notice a difference in taste of softened water, compared to what they're used to; and people who have to be very careful about their levels of sodium intake will need to add in to their calculations, the sodium in the water. It's a tiny amount, but it needs accounting for. Whereas if you use a descaler instead, then you'll need to make sure that the boiler is thoroughly rinsed before used for drinking water.