I couldn't visit you because of illness.

Literal

Illness [because-のため] you [object-を] visiting [could-not-できませんでした].

訪問できませんでした — 訪問する is a formal suru-verb for 'to visit.' The polite form and formal vocabulary make this an appropriate apology for a missed social obligation.