I can't do something is very definite. It is not possible to do something. It does not make clear whether any effort is involved.
Having trouble implies there is effort involved. "I am trying to do something but it is very difficult."
I good example would be driving.
"I can't drive." It could be because I don't know how or I had my license revoked or I am blind or I am 5 years old and I can't reach the pedals.
"I'm having trouble driving." I know how to drive but I am finding it difficult. It could be because I am sleepy or the car is giving mechanical trouble or I'm drunk or I'm fulfilling my wife's fantasy of having sex on the highway.