Conditions in a will are.. complicated.
As a rule of thumb you can impose conditions but that doesn't mean they are always going to be upheld.
Some will be ruled void where they are considered "against public policy" - where it's against the public interest to consider the condition valid. e.g:
- encouraging someone to commit a crime;
- inducing the future separation of a married couple;
- unreasonable restrictions on marriage;
- depriving a parent of control over their children;
- requiring a child to change their religion.
That sort of thing.
Another way is if the condition is "impossible" (or so improbable/impractical as would make no real difference) e.g. you can't say "they have to leap the grand canyon on a skateboard" or "must visit mars and bring back ice cream first" that sort of thing.
Alternatively if the condition is too vague or uncertain e.g. "the beneficiary will inherit when they are ‘suitably’ married" or impractical to enforce e.g. "no one with the surname Booth may enter the property on a Wednesday".
I'm not sure those are going to apply here - the condition sounds specific and not particularly difficult to achieve or to measure compliance. That doesn't mean it's going to stick though - you can challenge the condition in court and they might chose to void the condition. Since the condition sounds like what's called a "condition subsequent" (i.e. it comes into effect after receiving the "gift") the court can use discretion to have the gift still take place if the condition is voided.
How about if they were not allowed to sell it for 20 years, or 100?
The 100 years variant could fail under "impossible" - since it would take the time period the beneficiary was required to comply with the condition past the point they could reasonably be expected to comply with it (since people typically live that long), similarly with the 20 years (or even the 10) if it was going past the remaining expected lifespan of the recipient.
Basically it boils down to "challenge it in court and see what they say" - but as ever consult an experienced solicitor before doing anything along those lines. Having a condition declared void doesn't always translate as "you get it free and clear" - in some circumstances it means the gift becomes part of the Residuary Estate instead.