Can we create a rule where owners must own a unit for 5 years, before being allowed to offer that unit as a rental?
Yes, a homeowners association can prohibit rentals or restrict them. This will have the effect of discouraging investors from purchasing units within your community. However, such restriction cannot be adopted by the board as a rule. It must be adopted by the unit owners as an amendment to the by-laws. Most by-laws require a vote of at least 66 2/3 in number and in common interest of all unit owners at a meeting called for such purpose to approve a by-law amendment.
While the restriction can be applied retroactively, this may be unfair to current owners who purchased their units with the expectation that they can lease them. However, restriction can be applied retroactively inasmuch as purchasers in a homeowners association should be aware that the rules can be changed by the homeowners. Nevertheless, the board may want to "grandfather" the current homeowners from the rental restriction, especially if they need the current homeowners who are renting their homes to vote in favor of the amendment.
The board may also want to exempt from the restriction mortgagees who acquire title to the unit by foreclosure or by deed in lieu of foreclosure in order to promote lending against homes within the community.
The board may also want to consider including a "hardship" provision in the proposed amendment that would give the board discretion to allow exceptions to the restriction based on financial or other exceptional circumstances.