There's nothing wrong or illegal about giving someone money on the condition that they convert to a religion while alive, so why should it be illegal by way of will? I agree with the judgement on this basis.
Let's take something more extreme as an example. What if your child was a member of...