When a court is making a determination on the issue of exclusive possession of a matrimonial home, the following factors stated in section 24 (3) of the Family Law Act are considered:
(a) the best interests of the children affected;
(b) any existing orders under Part I (Family Property) and any existing support orders;
(c) the financial position of both spouses;
(d) any written agreement between the parties;
(e) the availability of other suitable and affordable accommodation; and
(f) any violence committed by a spouse against the other spouse or the children. R.S.O.
In some circumstances, exclusive possession is necessary for the peace, safety and stability of the parties involved and is granted to ensure that the best interests of the children are met.
http://www.canlii.org/en/on/laws/stat/rso-1990-c-f3/latest/rso-1990-c-f3.html#sec24subsec3_smooth