They are different ways of saying similar, but not identical things. To me they basically come across like this:
1) Someone took great pains to do something - someone tried very hard to do something something that may or may not be difficult. An example would be if someone put a lot of effort into dressing appropriately for a party, you could say "They took great pains to dress for the occasion".
2) Someone had so much trouble doing something - someone tried to do something and ran into many problems in the process. This sentence emphasizes the difficulty experienced by the person doing the thing, rather than the amount of effort they put into it / whether they were successful or not.
3) Someone made an effort to do something - someone merely attempted to do something. They did not necessarily try particularly hard, and the thing that was attempted was not particularly difficult
4) Someone worked so hard to do something - someone tried very hard to do something. The thing they worked at was not necessarily difficult, more that the sentence emphasizes the degree of effort they put into it.