The diode is to provide a safe path for the inductive kickback of the motor. If you try to switch off the current in an inductor suddenly, it will make whatever voltage is necessary to keep the current flowing in the short term. Put another way, the current thru an inductor can never change instantaneously. There will always be some finite slope.
The motor is partially an inductor. If the transistor shuts off quickly, then the current that must still flow thru the inductor for a little while will flow thru the diode and cause no harm. Without the diode, the voltage across the motor would get as large as necessary to keep the current flowing, which would probably require frying the transistor.
A small capacitor across the motor will reduce the speed of the possibly fast voltage transitions, which causes less radiation and limits the dV/dt the transistor is subjected to. 100 nF is excessive for this, and will prevent efficient operation at all but low PWM frequencies. I'd use 100 pF or so, perhaps to up 1 nF.
The resistor is to limit current the digital output must source and the transistor base must handle. The transistor B-E looks like a diode to the external circuit. The voltage will therefore be limited to 750 mV or so. Holding a digital output at 750 mV when it is trying to drive to 5 V or 3.3 V is out of spec. It could damage the digital output. Or, if the digital output can source a lot of current, then it could damage the transistor.
1 kΩ is again a questionable value. Even with a 5 V digital output, that will put only 4.3 mA or so thru the base: the voltage drop at the B-E junction ("diode") is 0.7 V, leaving the 4.3 V at the resistor. You don't show specs for the transistor, so let's figure it has a minimum guaranteed gain of 50. That means you can only count on the transistor supporting 4.3 mA x 50 = 215 mA of motor current. That sounds low, especially for startup, unless this is a very small motor. I would look at what the digital output can safely source and adjust R1 to draw most of that.
Another issue is that the 1N4004 diode is inappropriate here, especially since you will be turning the motor on and off rapidly, as implied by "PWM". This diode is a power rectifier intended for normal power line frequencies like 50-60 Hz. It has very slow recovery. Use a Schottky diode instead. Any generic 1 A 30 V Schottky diode will do fine and be better than a 1N4004.
I can see how this circuit can appear to work, but it clearly wasn't designed by someone that really knew what they were doing. In general, if you see an Arduino in a circuit you find on the 'net someplace, especially a simple one, assume it was posted because the author considers it a great accomplishment. Those that know what they are doing and draw out a circuit like this in a minute don't consider it worth writing up a web page on. That leaves those that took two weeks to get the motor to spin without the transistor blowing up and they're not really sure what everything does to write these web pages.
Without a proper load, there is nothingc to pull the drain high when you turn the MOSFET off, except the 10 megohms of your scope probe. That and the FET output capacitance give rise to the slow decay you see.
Make the same measurement with a resistor ( 1 kilohm or lower) in parallel with the probe, and observe the difference..
Best Answer
The circuit is rubbish. Apart from it being drawn as a cartoon of a wiring diagram, if you look closely, the GND pin on the UNO is connected to the drain pin of an unspecified (could be P ch or N ch) MOSFET. The power supply negative connection does not reach the UNO at all.
The resistor is placed between drain and gate is highly likely to also be in error.
The only conclusion is that the circuit was drawn by someone with little knowledge and has therefore no merit hence, to try and fathom out why the electrolytic capacitor is placed across the motor is of little point.
Stick to proper symbolic circuit diagrams from reputable sources.
If you read the user comments at the bottom of the page you linked you'll see that other folk have also pointed out several errors in the diagrams. Sites like that are basically an insult to engineering but, as a beginner, you are not to realize this so you have my sympathy.