I definitely would say RAM. Adding more RAM is about the quickest way to speed up a computer.
Especially at today's low prices, there's bargains on DDR4 RAM also, the market is saturated. RAM again gives the best 'bang for the buck'.
While the CPU is also important, there's a lot more going on in memory. Even the CPU has it's own, known as L1, L2 & notably on today's models, L3.
With that said.....
A.) A computer with a 1.5Ghz processor and 4GB of RAM
B.) A computer with a 4Ghz processor and 1.5GB of RAM ?
I'll take 'B' & stuff the RAM to the gills, because there's no such thing as 'wasted RAM'.
I once tried Option 'A' & the results were pathetic, 2nd link with SSD, not much better. Wished you had asked that one also, like RAM, easy on the wallet for common (or best selling) SATA-3 versions.
BTW, this very PC has a 4.0GHz CPU & 32GB of RAM, and the performance is excellent. Even with a HDD to drag down results, it's a killer machine, the one shown in my first Speccy snapshot.
Would I trade for System 'A'? Never again, nor will I purchase off the shelf PC's anymore. Find your bottlenecks & eliminate these by building it yourself, while getting a $2,800 PC (if performed by a custom PC builder) for a little more than half the price.
Keep the other half for a 2nd build, which I'm working on now.