I would argue that foreign investment plays almost no role.
Homes generate cashflows (rents). Rents are a function of local economy (paychecks). What one is willing to pay for a home is a function of rents, risks, interest rates and expected changes in rents, risks and interest rates.
If home prices are not detached from these fundamentals (and is there evidence that they are?), some investor is going to buy them, foreign or local.