Kevin,
I do not know why Mathematica is unable to do the integration with n=21. But
we may help Mathematica a little by integrating term by term in the
following way:
n = 21; Integrate[ # Sin[Pi x]]& /@ LegendreP[n, x] // Expand
With n=19, this command is more than twice as fast as the direct command
Integrate[ Sin[Pi x] LegendreP[n, x], {x, -1, 1} ], and it also works fast
for much higher values of n.
Of course you can trust the numerical conversion of your exact result when
working in high precision. That working in machineprecision fails is easy to
see when you compute the numerical values of each of the terms in the exact
result, e.g. by
N[List @@ result]
Many of the terms have an order of magnitude of 10^15, so that is is
surprising that nevertheless the sum is close to 0.
Regards,
Fred Simons
Eindhoven University of Technology