From heim (“home”) + wee (“pain, longing”), calque of German Heimweh; compare nostalgie, which (transmitted via French and New Latin) ultimately represents a calque of the same German word.
The form heim is a Germanism, but nonetheless heimwee prevailed over fully nativized heemwee, which is now obsolete.