Connectedness of the boundary

I have thought some more about this question and managed to complete the proof (assuming I haven't made any mistakes of course; comments welcome). Because of this, I have decided to reorganize my answer. (Note that the comment at the end of andrzejczarnecki's answer is referring to an earlier version of my answer. I've kept the notation $f$ for the map he is referring to.)

First, a word or two about the topological tools used. I have tried to use only basic topological tools, as the question asks. As suggested in the motivation below (see the example with the torus), the facts that $\mathbb R^n$ is simply connected while $S^1$ isn't, seem to be crucial. To treat simple connectedness in a reasonable way, I have decided to use the fundamental group.

Motivation

Let us consider some examples first.

First example. Let's examine the analogous problem for path-connectedness. The following example shows that the boundary might not be path-connected even if $A$ and $X\setminus A$ are (here $X = \Bbb R^n$): let $$A=\{(x,y)\in\Bbb R^2|\;y^2< 2+\sin\frac1{1-x^2}, x^2<1\}.$$ The boundary of this set is a bit similar to the topologist's sine curve and looks as follows:

enter image description here

As we can see, both $A$ and $X\setminus A$ are path-connected, but $\partial A$ isn't (by the same argument as for the topologist's sine curve).

Second example. Now, examine the analogous problem for the torus, i.e. instead of $X=\Bbb R^n$, let $X = S^1\times D^2$, where $S^1\subseteq\Bbb R^2$ is the unit circle and $D^2\subseteq\Bbb R^2$ is the closed unit disk. Let $S^1_+ = S^1\cap\Bbb R\times(0,\infty)$, i.e. the open upper half of the circle. Let $A=S^1_+\times D^2$. We notice that $A$ is connected, $X\setminus A$ is connected, but the boundary consists of two connected components, $\{(-1,0)\}\times D^2$ and $\{(1,0)\}\times D^2$.

Since the torus has very similar topological properties to $\Bbb R^n$ but is not simply connected, this leads us to the idea that a proof in the $X = \Bbb R^n$ case will probably have to use simple connectedness. This motivates the proof that follows.

Proof

Let $A\subseteq X = \Bbb R^n$, as in the question. Let $q:[0,1]\to S^1\subseteq\mathbb C$, $$q(t)=e^{2\pi it},$$ be the usual quotient map. Define $B=X\setminus(A\cup\partial A)$. Suppose $\partial A$ is disconnected. Then $\partial A = U\cup V$, where $U$ and $V$ are non-empty disjoint clopen sets in $\partial A$. Since $\partial A$ is closed in $X$, and $A$ is bounded, this implies $U$ and $V$ are compact. Therefore, we may define a continuous mapping $k:X\to[0,1]$ by $$k(x)=\frac12\frac{d(x,U)}{d(x,U)+d(x,V)}.$$ This enables us to define $f:X\to S^1$: $$f(x)=\begin{cases}q(k(x));&x\in A,\\q(1-k(x));&x\in X\setminus A.\end{cases}$$ Note that $$\begin{align}f(U)&=\{1\},\\f(V)&=\{-1\},\\f(A)&=S^1_+,\\f(B)&=S^1_-\end{align}$$ and that $f$ is continuous. ($S^1_+:=S^1\cap\{z\in\Bbb C|\; \Im{(z)}>0\}$ and $S^1_-:=S^1\cap\{z\in\Bbb C|\; \Im{(z)}<0\}$).

Next, we define a map $g:S^1\to X$. Let $a\in A$ and $b\in B$. Note that $A\cup B\cup U$ and $A\cup B\cup V$ are path-connected. Therefore there exist paths $$\gamma:[0,1]\to A\cup B\cup V,\\\gamma(0)=a,\\\gamma(1)=b\\$$ and $$\delta:[0,1]\to A\cup B\cup U,\\\delta(0)=a,\\\delta(1)=b.$$ Define $g$ as follows: $$g(q(t))=\begin{cases}\gamma(2t);&t\in[0,\frac12]\\\delta(2-2t);&t\in[\frac12,1]\end{cases}$$ This is again continuous.

Note the following properties of $f\circ g:S^1\to S^1$: $$\begin{align}(f\circ g)(\overline{S^1_+})&\subseteq S^1\setminus\{1\},\\(f\circ g)(\overline{S^1_-})&\subseteq S^1\setminus\{-1\},\\ (f\circ g)(1)&=f(a),\\ (f\circ g)(-1)&=f(b).\end{align}$$

Define homeomorphisms $h_+:S^1\setminus\{1\}\to(0,1)$ and $h_-:S^1\setminus\{-1\}\to(0,1)$ by $$h_+(q(t))=t$$ and $$h_-(q(t))=\begin{cases}t-\frac12;&t\in(\frac12,1],\\t+\frac12;&t\in[0,\frac12).\end{cases}$$

Using these, we construct a basepoint-preserving homotopy $H:(S^1,1)\times I\to (S^1,f(a))$. Define it as follows: $$H(z,s)=\begin{cases}h_+^{-1}\big((1-s)(h_+\circ f\circ g)(z)+s\cdot h_+(z\cdot f(a))\big);&z\in\overline{S^1_+},\\h_-^{-1}\big((1-s)(h_-\circ f\circ g)(z)+s\cdot h_-(z\cdot f(a))\big);&z\in\overline{S^1_-}.\end{cases}$$

(Most properties are easy to see. Observe that $h_-(z)=h_+(z)-\frac12$ for $z\in S^1_-$ to prove that this is well-defined for $z=-1$.)

This shows that the maps $f\circ g:S^1\to S^1$ and $z\mapsto f(a)\cdot z$ are homotopic relative to $1$, so they induce the same homomorphism $\varphi:\pi_1(S^1,1)\to\pi_1(S^1,f(a))$. But the second of these maps induces a nontrivial homomorphism, since multiplying by $f(a)^{-1}$ would take us back to the identity. So $\phi=(f\circ g)_*$ is nontrivial. Therefore, $f_*:\pi_1(\mathbb R^n,a)\to \pi_1(S^1,f(a))$ is also nontrivial. This contradiction completes the proof. $\square$


This is true in general: a connected open set $A$ in $\mathbb{R}^n$ has disconnected complement if and only if it has disconnected boundary.

The "only if" follows from $\mathbb{R}^n$ being normal.

As for the "if", consider that $\partial A$ has two components, $X$ and $Y$. Neither of them can lie in the interior of closure of $A$ (it is then a clopen set in the complement of $A$, and we assumed it to be connected). So assume to the contrary, and this actually means that both $X$ and $Y$ have points from the closure of interior of complement of $A$ (don't worry, that was the longest:), say $x$ and $y$. Now you can connect $x$ to $y$ by a curve through $A$ (we can do such things in $\mathbb{R}^n$), and then connect $y$ to $x$ with a curve through the complement of $A$ (we need that nonempty interior of complement for that). This gives a loop that cannot be homotoped to constant, yet $\mathbb{R}^n$ is simply connected, a contradiction.

This cannot be done non-homotopically. The equivalence as I stated it characterises (is equivalent) to the ambient space having trivial first cohomology. The map $f$ from Deian Govc's answer cannot exist precisely because it would give a nontrivial cohomology class.