What is the function of "根本" in 这杯咖啡根本不值得花四十元人民币?
Yes, you can remove it without changing the meaning of the sentence. 
'根本' in here is just for emphasis. Like 'at all' in English. 


I'm afraid I have nothing (at all) to say.
It wasn't difficult (at all).


And you can't see 'at all' as an adverb, right? 
But indeed, '根本' is like an adverb in use.



Meaning：


根：root
本：basis
根本：radical / radically
To help comprehension, '根本' can be extended as '从根本上来说' which means 'fundamentally speaking' or 'basically'. 




Examples:

BackgroundA-1： A man killed a man with a kitchen knife. 
You can say: 
他不是人：He is not a human. (Because what he did is beyond an average person will do)

BackgroundA-2： A man killed a man with a kitchen knife without any guilty, moreover, he dismembered the body and ate. 
You can say: 
他根本不是人：He is completely not a human. (He is totally insane.)

BackgroundB-1： An actress tends to improvise instead of according to the scripts. 
You can say： 
她拍戏经常不用剧本，都是即兴发挥：She usually improvising in filming, not always follow the scripts blindly. (She is good.)

BackgroundB-2： An actress completely off the scripts just acts by improvising. 
You can say： 
她拍戏根本不用剧本，都是即兴发挥：She improvised in everyday shooting without any single script at all.(She is outstanding./She is weird.)

In fact, the difference isn't so obvious in everyday use, you can add '根本' into the sentence whenever you expressing your strong emotion.



Back to the context you mentioned. We can enrich it to feel the difference.


If the coffee tasted may not so bad, but not good enough as you expected. You could say：这杯咖啡不值得花四十元人民币 (Said calmly)
If the coffee tasted bad, and you buy it because previously the waitress highly recommended it for the cost-effectiveness.You could say：这杯咖啡根本不值得花四十元人民币 (Said in a little irritated mood)


By the way, to avoid wordy in colloquial, we tend to put it this way: 这咖啡根本就不值四十！



In a word, yes, '根本' can be removed in such sentences, but removed it may also play down the fact into understatement.