Let $A$ be any ring, commutative with identity, and let $I\subset A$ be an ideal $\neq A$. Let $U\subset{\rm Spec}(A)$ be the open subscheme obtained by "removing" the closed set $V(I)$ of all the prime ideals of $A$ containing $I$. Is there a criterion on the ideal $I$ that enables one to decide whether $U$ is an affine scheme?

This question has been studied on and off for a while. As pointed out in the comments, an interesting necessary and sufficient condition in full generality will be hard to find, but there are many related results in different directions. Here are two references: Holger Brenner: "On superheight conditions for the affineness of open subsets". Amnon Neeman: "Steins, Affines and Hilbert's Fourteenth Problem" For example, 4.4 of the first paper (see also 5.5 of the second) states that if $A$ is a domain of finite over $\mathbb C$ and $U\subset X = \text{Spec} A$ open such that $\Gamma(U,\mathcal O_X)$ is a finite generated $\mathbb C$algebra. Then $U$ is affine iff $U^{an}$ is Stein. Here is a simple necessary condition that is of interest to some algebraists. For simplicity I will assume our rings are Noetherian. Since preimage of affine is affine, one conclude that for any ring homomorphism $A\to B$, the ideal $IB$ also has height one. This gives simple nonexamples. Take $A=k[x,y,u,v]/(xuv)$, $I=(x,y)$, $B=A/(u,v)=k[x,y]$. Then the height of $IB$ is $2$, so $U$ can't be affine. The condition that the height of $I$ remains at most one in all extensions is called "$I$ has superheight one". Krull's Hauptidealsatz can be viewed as saying the superheight of $I=(T)$ in $\mathbb Z[T]$ is one! This point of view leads to many nontrivial generalizations, and some of the most notorious open questions in the field can be stated as a very simple question involving superheights. 

