Is a home (primary residence) purchase a form of investment in macroeconomics?
Home construction is a form of investment, home purchase is not. There's an important macro difference between creating the capital asset (construction) and transferring it (purchase).

Regarding whether a newly built home occupied by its owner counts as investment— yes, because it is a capital asset that produces a stream of housing services. There's more detail on how this fits into GDP in this answer.