Glen_b's answer is good enough for all practical purposes, but I'll include here the computation of the exact probability (computer-assisted, but I think it could be done by hands with enough time, courage and a few additional tricks). There are 2598960 possibilities of choosing 5 cards among 52. It is fast enough for a computer to test every possibility, but we can be smarter.
When choosing 5 cards among 52, how many cards of different heights can we get? There are 6 possibilities, or partitions (the partition number of 5 minus 1, because we can't get 5 cards of the same height):
- (1,1,1,1,1) (all the heights are distinct)
- (1,1,1,2) (a pair)
- (1,2,2) (double pair)
- (1,1,3) (three of a kind)
- (2,3) (full house)
- (1,4) (four of a kind)
In addition, there are respectively 1024, 384, 144, 64, 24 and 4 different ways of realizing one of these hands when the number of cards at each height are given (e.g. if I tell you that you have one "eigth" and four "King", that corresponds to 4 differents hands, depending on the colour of the "eigth"). These numbers are weights.
Now, for each partition, we compute how many heigths give rise to a sum of at least 40. For instance, for (1,4), we have to find the number of solutions of $x+4y \geq 40$ under the constraints $1 \leq x,y \leq 13$ and $x \neq y$. For the last four partitions, it can be done manually (it is easy for the last two ones), but the computer is very handy for the first two. We find respectively 337, 916, 291, 326, 59 and 64 favourable outcomes. If we multiply by the weights and sum, this yields 760092 favourable outcomes.
Hence, the probability of getting at least 40 is:
$$\frac{761272}{2598960} = \frac{95159}{324870} \simeq 0,293$$
This method may seem complicated, especially given that the problem can be brute-forced, but we have reduced the number of possibilities to check from 2,5 millions to about 5 thousands, not too far from being doable without a computer (and, at least, there are some interesting mathematics).
Edit: the error has been corrected. I just made a typo when I computed $337*1024+916*384+291*144+326*64+59*24+64*4 = 761272$ (my message initially gave this sum at 760092). The reasoning is sound.