How does a capacitor work as a filter in rectifier circuits (with equations)?
Above circuit-diagram represents the use of a smoothing capacitor in a rectified output. For sake of convenience, let's assume that the output is generated from a full-wave rectifier, hence supplying a varying DC output in the entire cycle with double the frequency than that of its AC source.

The output voltage in case of using a load resistance alone follows the input voltage from peak to zero. But in this case, we have a capacitor attached in parallel to the load resistance, which charges during the rising-edge of the waveform, and since it cannot discharge quickly (remind yourself of the RC time constant here), it will slowly discharge during the falling-edge, but even before it reaches zero, it meets the next rising-edge of the waveform. [Worth noting here is that the slope of charging and discharging curves  aren't equal].

This is the initial phase when you first switch-on the circuit and Capacitor takes time to stabilize to a particular value:


(Image credits and suggested further reading: http://www.skillbank.co.uk/psu/smoothing.htm)

And this is how it follows:

(Image credits: @JohnFu's answer here: How does a capacitor smooth energy?)
So, this continues on and on, creating a near-uniform DC voltage output, which is now, of course, not following the input voltage value but has its own value to the load resistance.

As far as the equation is concerned:

Ripple Voltage Vr = The degree of smooth DC output (by the capacitor in this case) = the  peak-to-peak voltage in the DC output by the capacitor

Vr = I(across load) / (frequency x Capacitance)