Hi Ilya. My name is Nico. I am a Professional English Teacher and a Lawyer. To answer your question, we would have to go to the origin of these words (i.e, how these words were derived).
Your question, is definitely relevant and it is something many people studying English has wondered before. Even scholars, have wondered about this question previously.
Whilst at present there is no exact answer, researchers have often suggested that the word "fruit" was already uncountable in Middle English, where it appeared from the Latin word "fructus", meaning product, result, effect (also related to "frux - fruges", meaning crop, harvest).
Whilst many scholars of English, do not have exact answers, it has often been accepted that the word originally was understood to mean "product" in a collective sense, so "fruit" was not the singular fruit as we know today, but rather what had been grown or produced, hence it is uncountable.
It is often further been addressed in English literature that the word "fruits" later came to be associated with the figurative sense of the word, as in "The fruits of your labor" and thereafter transferred to the plural.
"Vegetable" in the sense of "plant cultivated for food" is more recent. This was first recorded in the late 1700s.
Sometimes grammar is more related to habit and use than pure logic. For instance, "news" used to be countable, but now is always uncountable. Why? Because people started to use it that way and it stuck.
I hope this addresses your query. If you would like to discuss countable and uncountable further, please do not hesitate to contract me.