You basically ask about the sum $$ \sum_{n \le x} \alpha(n)$$ where $\alpha$ is a completely multiplicative function with $\alpha(p) = \mathbf{1}_{p \notin \mathcal{P}}$. This is addressed by Wirsing in his famous paper ``Das asymptotische Verhalten von Summen über multiplikative Funktionen'' (Math. Ann. 143 (1961), 75–102). The only requirement on $E$ is $E(x)=o(\pi(x))$, and it gives the asymptotic result $$(\star)\, \sum_{n \le x} \alpha(n) \sim\frac{ e^{-\gamma (1-\kappa)}}{\Gamma(1-\kappa)} \frac{x}{\log x} \prod_{p \le x,\, p \notin \mathcal{P}}(1-1/p)^{-1},$$ where $\gamma$ is the Euler-Mascheroni constant (appearing also in Mertens' theorem). Remark 1: Suppose $\sum_{p \le x, p \in \mathcal{P}} 1/p = \kappa\sum_{p \le x} 1/p +C + o(1)$, which holds if $E(x)$ is small enough, say $O(x/\log^{1+\varepsilon} x)$ (by partial summation). Then $$C(\mathcal{P}) :=\frac{ 1}{\Gamma(1-\kappa)} \prod_{p \notin \mathcal{P}}(1-1/p)^{-1} \prod_{p}(1-1/p)^{1-\kappa}$$ converges and the last result may be simplified as $$C(\mathcal{P})\frac{x}{(\log x)^{\kappa}},$$ by Mertens. This should recover the result from Iwaniec and Kowalski. Remark 2: In Wirsing's sequel to his own paper, ``Das asymptotische Verhalten von Summen über multiplikative Funktionen. II'' (Acta Math. Acad. Sci. Hungar. 18 (1967), 411–467) he relaxes the condition on $\mathcal{P}$ even further, requiring less than positive relative density, while still retaining $(\star)$.