[proofplan]
We prove the theorem by converting the restriction question into a relative cohomology vanishing statement for the pair $(X,Y)$. The complement $U := X \setminus Y$ is affine, and the Andreotti-Frankel theorem implies that $U$ has the homotopy type of a CW complex of real dimension at most $n$. Lefschetz duality identifies the relative cohomology groups $H^m(X,Y;\mathbb{Z})$ with the high-degree homology of $U$, which therefore vanishes for $m < n$. The [long exact cohomology sequence](/theorems/3471) of the pair then gives isomorphy below degree $n-1$ and injectivity in degree $n-1$.
[/proofplan]
[step:Identify the affine complement and its homological dimension]
Define the open complement
\begin{align*}
U := X \setminus Y.
\end{align*}
Since $Y = X \cap H$ is a hyperplane section, the complement $U$ is the closed submanifold $X \cap (\mathbb{P}^N \setminus H)$ inside the affine chart $\mathbb{P}^N \setminus H \cong \mathbb{C}^N$. Hence $U$ is a smooth affine complex manifold of complex dimension $n$.
By the Andreotti-Frankel theorem (citing a result not yet in the wiki: Andreotti-Frankel Theorem), the affine complex manifold $U$ has the homotopy type of a CW complex $K$ of real dimension at most $n$. Therefore
\begin{align*}
H_j(U;\mathbb{Z}) \cong H_j(K;\mathbb{Z}) = 0
\end{align*}
for every integer $j > n$.
[guided]
We isolate the topological input. Define
\begin{align*}
U := X \setminus Y.
\end{align*}
Because $Y$ is obtained by intersecting $X$ with the hyperplane $H$, the complement $U$ is the part of $X$ lying in the affine chart $\mathbb{P}^N \setminus H$. This affine chart is isomorphic to $\mathbb{C}^N$, so $U$ is a smooth affine complex manifold of complex dimension $n$.
The Andreotti-Frankel theorem applies precisely to smooth affine complex manifolds. It says that such a manifold of complex dimension $n$ has the homotopy type of a CW complex of real dimension at most $n$ (citing a result not yet in the wiki: Andreotti-Frankel Theorem). Thus there exists a CW complex $K$ of real dimension at most $n$ and a homotopy equivalence $K \simeq U$. Homotopy invariance of singular homology gives
\begin{align*}
H_j(U;\mathbb{Z}) \cong H_j(K;\mathbb{Z}).
\end{align*}
Since $K$ has no cells in dimensions strictly larger than $n$, its cellular chain groups vanish in those dimensions, and hence
\begin{align*}
H_j(K;\mathbb{Z}) = 0
\end{align*}
for every integer $j > n$. Consequently
\begin{align*}
H_j(U;\mathbb{Z}) = 0
\end{align*}
for every integer $j > n$.
[/guided]
[/step]
[step:Convert high-degree homology of $U$ into relative cohomology of $(X,Y)$]
For each integer $m$, Lefschetz duality for the compact oriented real $2n$-manifold $X$ and the closed oriented codimension-$2$ submanifold $Y$ identifies
\begin{align*}
H^m(X,Y;\mathbb{Z}) \cong H_{2n-m}(U;\mathbb{Z})
\end{align*}
up to the standard orientation local system, which is trivial because $X$ is a complex manifold and therefore canonically oriented. This is the form of Poincare-Lefschetz duality for the complement of a closed submanifold (citing a result not yet in the wiki: Poincare-Lefschetz Duality for Complements).
If $m < n$, then $2n-m > n$. The homology vanishing from the previous step gives
\begin{align*}
H_{2n-m}(U;\mathbb{Z}) = 0.
\end{align*}
Therefore
\begin{align*}
H^m(X,Y;\mathbb{Z}) = 0
\end{align*}
for every integer $m < n$.
[guided]
The goal is to prove that the map $H^k(X;\mathbb{Z}) \to H^k(Y;\mathbb{Z})$ is close to an isomorphism. The long exact sequence of the pair $(X,Y)$ shows that this is controlled by the relative groups $H^m(X,Y;\mathbb{Z})$, so we now prove that these groups vanish in low degree.
The space $X$ is a smooth complex projective manifold of complex dimension $n$, hence a compact oriented smooth real manifold of real dimension $2n$. The subspace $Y \subset X$ is a smooth complex hypersurface, hence a closed oriented real codimension-$2$ submanifold. Since complex manifolds carry canonical orientations, the relevant orientation local systems in Lefschetz duality are trivial. Applying Poincare-Lefschetz duality for complements gives an isomorphism
\begin{align*}
H^m(X,Y;\mathbb{Z}) \cong H_{2n-m}(U;\mathbb{Z})
\end{align*}
for every integer $m$ (citing a result not yet in the wiki: Poincare-Lefschetz Duality for Complements).
Now suppose $m < n$. Then
\begin{align*}
2n - m > n.
\end{align*}
The previous step proved that the homology of $U$ vanishes in all degrees strictly greater than $n$, so
\begin{align*}
H_{2n-m}(U;\mathbb{Z}) = 0.
\end{align*}
Using the duality isomorphism, we obtain
\begin{align*}
H^m(X,Y;\mathbb{Z}) = 0
\end{align*}
for every integer $m < n$.
[/guided]
[/step]
[step:Use the long exact sequence of the pair to obtain isomorphy below degree $n-1$]
Let $k$ be an integer with $k < n-1$. The long exact cohomology sequence of the pair $(X,Y)$ contains the segment
\begin{align*}
H^k(X,Y;\mathbb{Z}) \longrightarrow H^k(X;\mathbb{Z}) \xrightarrow{i^*} H^k(Y;\mathbb{Z}) \longrightarrow H^{k+1}(X,Y;\mathbb{Z}).
\end{align*}
Since $k < n-1$, both $k < n$ and $k+1 < n$. The relative vanishing from the previous step gives
\begin{align*}
H^k(X,Y;\mathbb{Z}) = 0,
\qquad
H^{k+1}(X,Y;\mathbb{Z}) = 0.
\end{align*}
Exactness therefore implies that $i^*:H^k(X;\mathbb{Z}) \to H^k(Y;\mathbb{Z})$ is both injective and surjective. Hence $i^*$ is an isomorphism for every $k < n-1$.
[guided]
Fix an integer $k$ satisfying $k < n-1$. We use the long exact cohomology sequence associated to the pair $(X,Y)$ (citing a result not yet in the wiki: [Long Exact Sequence of a Pair](/theorems/2249) in Cohomology). The relevant part is
\begin{align*}
H^k(X,Y;\mathbb{Z}) \longrightarrow H^k(X;\mathbb{Z}) \xrightarrow{i^*} H^k(Y;\mathbb{Z}) \longrightarrow H^{k+1}(X,Y;\mathbb{Z}).
\end{align*}
The map in the middle is exactly the restriction map induced by the inclusion $i:Y \hookrightarrow X$.
Because $k < n-1$, we have both
\begin{align*}
k < n,
\qquad
k+1 < n.
\end{align*}
The relative cohomology vanishing proved above therefore gives
\begin{align*}
H^k(X,Y;\mathbb{Z}) = 0,
\qquad
H^{k+1}(X,Y;\mathbb{Z}) = 0.
\end{align*}
Exactness now has two consequences. Since the group before $H^k(X;\mathbb{Z})$ is zero, the kernel of $i^*$ is zero, so $i^*$ is injective. Since the group after $H^k(Y;\mathbb{Z})$ is zero, the image of $i^*$ is all of $H^k(Y;\mathbb{Z})$, so $i^*$ is surjective. Thus $i^*$ is an isomorphism for every integer $k < n-1$.
[/guided]
[/step]
[step:Use the same exact sequence to obtain injectivity in degree $n-1$]
For $k = n-1$, the long exact sequence of the pair contains
\begin{align*}
H^{n-1}(X,Y;\mathbb{Z}) \longrightarrow H^{n-1}(X;\mathbb{Z}) \xrightarrow{i^*} H^{n-1}(Y;\mathbb{Z}).
\end{align*}
Since $n-1 < n$, the relative vanishing gives
\begin{align*}
H^{n-1}(X,Y;\mathbb{Z}) = 0.
\end{align*}
Exactness implies
\begin{align*}
\ker\left(i^*:H^{n-1}(X;\mathbb{Z}) \to H^{n-1}(Y;\mathbb{Z})\right)=0.
\end{align*}
Thus $i^*$ is injective in degree $n-1$, completing the proof.
[/step]