As has been pointed out by @CuriousOne you can save the energy but let's me first explain the context in which one usually first meet this loss of energy. A capacitor $C$ in series with a resistor $R$ and a voltage source $V$ is charged. If the final charge on the capacitor is $Q$ then the work done by the voltage source is $VQ$ and as $Q=CV$ the work done by the source is $CV^2$. The energy stored in the capacitor is $\int_0^QVdQ = \int_0^Q\frac Q C dQ = \frac 1 2 CV^2$. The integration has to be done because as the capacitor is charged the voltage across its plates changes. The missing energy is $\frac 12 CV^2$ and that is lost as heat in the resistor. To show that is true and the loss is independent of the value of the resistance in the circuit one must do a bit more circuit analysis. During the charging process it can be shown that the current in the circuit $I(t) = \frac V R e^{-\frac {t}{RC}}$. The power dissipated in a resistor is $I^2R$ so during the changing process the energy dissipated in the resistor is $\int_0 ^\infty \frac {V^2}{R^2} e^{-\frac {2t}{RC}} dt = \frac 1 2 CV^2$. --- If the capacitor is charged in the way described changing the resistance value will not change the amount of energy lost as heat. If the resistance in becomes very low instead of the charging process following an exponential curve the current in the circuit becomes a damped sinusoid and then energy is lost as heat and electromagnetic waves because the electrons in the wires are accelerating and unbound accelerating charges emit electromagnetic radiation. --- The factor $\frac 1 2$ comes into play in lots of other situations eg the energy stored in an inductor $\frac 1 2 LI^2$ and in a spring $\frac 1 2 k x^2$. In all these cases the "missing" energy turns up as heat due to the resistance in an electrical circuit and friction in the mechanical example. Using Hooke’s law for a spring of spring constant $k$ which has a static extension of $x$ when a weight $mg$ is hung from its end $mg= kx$. The work done by the gravitational force is $mgx = kx^2$ whereas the energy stored in the spring is $\frac 12 k x^2$ In this case imagine releasing the mass when the spring is unextended. What would happen? The mass would oscillate about the static extension position and as frictional forces converted mechanical energy into heat the mass would eventually reach the static extension position. --- So how can you save that missing energy? One reason for introducing the spring is that perhaps discussing the motion of a spring-mass system makes it easier to understand an answer to this question? What you do is, with the spring unextended, release the mass and catch hold of the mass when it first stops after half a period. If there are no frictional forces this will happen when the extension of the spring is $2x$. The work done by the gravitational force is now $mg 2x = 2kx^2$. The energy stored in the spring is $\frac 1 2 k (2x)^2 = 2 k x^2$ which is exactly equal to the work done by the gravitational force. No energy wasted as heat. --- So what about the capacitor? Here you need as small a resistance value in the circuit as possible so that the voltage across the capacitor oscillated between 0 and 2V about V (the final voltage value), just like the spring. In this case you disconnect the capacitor from the voltage source after half a period when the voltage across the capacitor is 2V. The work done by the voltage source is now $V 2Q = 2CV^2$. The energy stored in the capacitor is $\frac 1 2 C (2V)^2 = 2 CV^2$ which is exactly equal to the work done by the voltage source. No energy wasted as heat. You have all the energy supplied by the voltage source stored in the capacitor.