Why PWM does not regulate voltage across MOSFET?
Of course you get 4.99V.  Why wouldn't you?  There is nothing that would cause the behavior you're expecting.  What you're expecting is for the output to behave as if it had been filtered through a low pass filter, and actively discharged through said filter according to the PWM duty cycle, not simply charged. With a negligible load attached.
If all you have is a capacitor and small parallel resistor with the ground line being switched by the MOSFET, duty cycle will not have any effect on the voltage.
When the MOSFET turns on, the capacitor (having fairly low ESR) will charge as fast as it possibly can - much much faster than 100KΩ will discharge it.  By my estimates, assuming the capacitor has an ESR of 1Ω (a bit on the high side but not unusual for a small aluminum electrolytic capacitor), even at 1/256th duty cycle, it will charge up to 4.99V in about 40ms.
Your setup is not a filter, but essentially a peak detector.  It will always charge to a voltage that is the peak voltage it sees.  Duty cycle will not change this voltage, just how long it takes to reach it (which at the lowest duty cycle is in about 1/25th of a second).
If you want the voltage to vary with duty cycle, you must:

Use a low pass filter
Charge and discharge the capacitor through that filter, with PWM on/off corresponding to charge/discharge of the capacitor.

The simplest low pass filter is a resistor in series with a capacitor.  If we let the capacitor be passively charged by connecting it through a high value series resistor to +5V, then we can connect the MOSFET so that it will discharge the capacitor when the output pin is HIGH like so:

The 330Ω resistor is to limit the current from the power supply through the MOSFET.  But that, along with the low pass filter formed by R1 and C1, should give you a voltage that more or less varies with duty cycle.
This is of course impractical for anything beyond simple 'analog out' type applications.  You can't use this to vary the voltage for any meaningful load.
If you want something more like a variable output power supply, it cannot be done this way.  That requires active regulation (since you will have a variable load) as well as using an inductor instead of the resistor (since any series resistor will dissipate far too much power while limiting the current), using a diode etc.
In other words, making a buck converter.  But that's out of scope.