Well, I got further info and I am afraid the issue is much more complex than what I expected.
I succeded in booting Ubuntu from a USB drive and the trackpad and the keyboard worked well, no problems at all and also screen luminosity and keyboard light keys worked. Instead, when booting in Mac OS (El Capitan) I had the usual problem.
I also replaced the original Apple flex cable with a new one (the same that previously I thought being defected) and in Ubuntu it works, as well.
At the beginning I thought it was a software problem (Ubuntu works, Mac OS not) but going through several forums and by reading the system logs (where HSSPI errors appear) I understood that the issue is related to the SPI protocol used by Mac OS for accessing to the internal keyboard/trackpad. When using only the USB protocol (Ubuntu) everything works.
On the other hand sometimes (I have no clue about when and/or under which conditions) things work for a while with the original cable (and perhaps also with the new one, but it didn't happen up to now): last time it worked for about ten days.
At this point it could be a hardware problem related to the trackpad controller or also to the logic board but it is difficult to understand before trying to replace them (and replacing the logic board is very expensive). I still have the doubt about a firmware problem: I know that Apple updated MacBook 2013 firmware for solving keyboard/trackpad issues and that might be the same. It may be worth to know whether someone had such problems that disappeared after upgrading to High Sierra or later release (I know that the problem arises in El Capitan and Sierra for sure). I also tried to upgrade to High Sierra but my machine refuses to do that (the process get stuck in updating from the Recovery state, perhaps due to a Windows partition I created with Bootcamp....).
In conclusion I cannot see an "easy exit strategy": the problem can be hardware and then solving it can be anti-economic (better to buy a new Macbook) or even software/firmware and in that case it is unreasonable that Apple didn't give the opportunity to solve (a firmware/software specific update for such machines or also some way for disabling SPI access to the keyboard/trackpad). I reported all such considerations that might be of some help (at least to understand what's going on) for other people.