The Universal Coefficient Theorem for cohomology states that there is an exact sequence
$$0 \to \operatorname{Ext}^1_{\mathbb{Z}}(H_{n-k-1}(M; \mathbb{Z}), \mathbb{R}) \to H^{n-k}(M; \mathbb{R}) \to \operatorname{Hom}_{\mathbb{Z}}(H_{n-k}(M; \mathbb{Z}), \mathbb{R}) \to 0.$$
As $\mathbb{R}$ is a divisible abelian group (and hence, an injective $\mathbb{Z}$-module), the first group vanishes and $H^{n-k}(M; \mathbb{R}) \cong \operatorname{Hom}_{\mathbb{Z}}(H_{n-k}(M; \mathbb{Z}), \mathbb{R}) \cong \mathbb{R}^{b_{n-k}(M)}$. So if $H^{n-k}(M; \mathbb{R}) \cong \mathbb{R}$, we see that $b_{n-k}(M) = 1$.
If $M$ is orientable, then by Poincaré duality $b_k(M) = b_{n-k}(M) = 1$, so $\operatorname{rank}H_k(M; \mathbb{Z}) = 1$, i.e. $H_k(M; \mathbb{Z})$ is of the form $\mathbb{Z}\oplus T$ for some finitely generated abelian torsion group $T$. Note that $T$ need not be zero. For example, let $M = (S^1\times S^2)\#\mathbb{RP}^3$. Then one can show that $H^2(M; \mathbb{R}) \cong \mathbb{R}$ and $H_1(M; \mathbb{Z}) = \mathbb{Z}\oplus\mathbb{Z}_2$; see this answer for the computation of (co)homology groups of a connected sum.
If $M$ is non-orientable, then we need not even have $b_k(M) = 1$. For example, let $M = \mathbb{RP}^4\#\mathbb{RP}^4$. Then $H^3(M; \mathbb{R}) \cong \mathbb{R}$ but $H_1(M; \mathbb{Z}) \cong \mathbb{Z}_2\oplus\mathbb{Z}_2$.
What follows addresses the discussion in the comments.
Let $M$ be a closed manifold. Then there are finitely generated abelian torsion groups $T_i$ and $T^i$ such that $H_i(M; \mathbb{Z}) \cong \mathbb{Z}^{b_i(M)}\oplus T_i$ and $H^i(M; \mathbb{Z}) \cong \mathbb{Z}^{b_i(M)}\oplus T^i$. It follows from the Universal Coefficient Theorem that $T^i \cong T_{i-1}$. If $M$ is orientable, then we also have $T^i \cong T_{n-i}$ by Poincaré duality. If $\dim M = 4$, this leaves only one possible torsion group: $T^3 \cong T_2 \cong T^2 \cong T_1$. In particular, a closed orientable four-manifold has torsion in its homology/cohomology if and only if it has torsion in $H_1$. It follows that a simply connected closed four-manifold has no torsion in its homology/cohomology because such a manifold is orientable and has $H_1 = 0$. This conclusion is no longer true in higher dimensions. For example, the Wu manifold $W = SU(3)/SO(3)$ is simply connected, but $H_2(W; \mathbb{Z}) \cong \mathbb{Z}_2$; see this answer.