Created a function with roots at primes and only primes, are there useful applications?

Your function simplifies to $$(-1)^{4((x-1)!+1)/x}-1$$ and is just a restatement of Wilson's theorem: $(n-1)!\equiv-1\bmod n$ iff $n$ is prime.

If $x$ is prime, $((x-1)!+1)/x=k$ is an integer and $(-1)^{4k}-1$ evaluates to zero. If $x$ is composite and $\ge6$, $k=n+\frac1x$ where $n$ is an integer, so $(-1)^{4k}-1$ does not evaluate to zero. The function evaluated at $x=4$ gives $k=7/4$, which makes $(-1)^{4k}-1=-2\ne0$.


As far as I know it's the first of its kind.

It is certainly not. The function

$$f(x)=\begin{cases}0 & \text{ if } x \text{ is prime}\\ 1& \text{otherwise}\end{cases}$$

is also a function for which $f(x)=0$ if and only if $x$ is prime.

Also, replacing $4$ with $2$ seems to maintain the property.