Inverse DFT of $-i\pi \text{ sgn}(f)$
There are two issues here. First of all, you go from continuous time to discrete time, and second, you go from a continuous spectrum to a sampled spectrum. Note that the impulse response of an ideal discrete-time Hilbert transformer with frequency response

$$H(e^{j\omega})=-j\text{ sgn}(\omega),\qquad \omega\in[-\pi,\pi]\tag{1}$$

is given by

$$h[n]=\frac{1}{2\pi}\int_{-\pi}^{\pi}H(e^{j\omega})e^{jn\omega}d\omega=\begin{cases}\frac{2}{n\pi},&amp; n\textrm{ odd}\\0,&amp;n\textrm{ even}\end{cases}\tag{2}$$

So the zero samples at even indices don't come as a surprise.

However, with your method you don't get $(2)$ because you sample the spectrum, which results in aliasing in the time domain. You also get a non-zero imaginary part because your discrete spectrum does not satisfy the condition

$$X[k]=X^*[N-k]\tag{3}$$

where $^*$ denotes complex conjugation. Using the following definition for $X[k]$ will give you a purely real-valued time-domain sequence (up to numerical errors):

$$X[k]=\begin{cases}0,&amp;n\in \{0,N/2\}\\
-j,&amp; n=1,\ldots,N/2-1\\
j,&amp;n=N/2+1,\ldots,N-1\end{cases}\tag{4}$$

where I've assumed that $N$ is even.

The inverse discrete Fourier transform (IDFT) of $(4)$ is given by

$$x[n]=\frac{1}{N}\sum_{k=0}^{N-1}X[k]e^{j2\pi kn/N}=\begin{cases}\frac{2}{N}\cot\left(\frac{\pi n}{N}\right),&amp;n\text{ odd}\\0,&amp; n\text{ even}\end{cases}\tag{5}$$

Consequently, it is expression $(5)$ which you should expect instead of a sampled version of $1/\pi t$. Of course, $(5)$ approximates $(2)$, but the approximation gets worse for increasing magnitude of the index $n$ ($n\in [-N/2,N/2-1])$: