The reason is that you're using machine-precision input, so the result you get will always be machine precision.
N[LegendreP[5, 0.1], 20]
0.17882875
Precision /@ {0.1, 0.17882875`}
{MachinePrecision, MachinePrecision}
To get result in arbitrary precision you can use exact input or non-machine precision input (which is what happened when you used the integer 1
):
N[LegendreP[5, 1/10], 20]
0.17882875000000000000
Notice the following:
N[LegendreP[5, #], 18] & /@ {0.1000000000000000, 0.100000000000000000}
{0.17882875, 0.17882875000000000}
What happens here is that $MachinePrecision
returns 15.9545898
on my machine, so any input with less than or equal to 16 digits will result in Mathematica using machine-precision for the computation, whereas anything greater is considered arbitrary precision and will be treated as such. Which is why the first input with 16 digits (machine precision) ignored our request for arbitrary precision output.