What are the necessary and sufficient conditions for a wavefunction to be physically possible? Often times it is stated in books that a quantum state is physically realizable only if it is square integrable. For example, in Griffiths (2018 edition) page 14 he stated

Physically realizable states correspond to the
square-integrable solutions to Schrödinger’s equation.

But when we have an operator with continuous eigenvalues like the position operator $\hat{X}$ our eigenstates are not square-integrable. Like the eigenfunction for the eigenvalue $x'$ of $\hat{X}$ is $\delta(x-x')$ which is not square-integrable and we also know -
$$ \langle x|x'\rangle=\delta(x-x')\Rightarrow \langle x|x\rangle=\infty$$
But clearly $|x\rangle$ is a physical state as wavefunction collapses to that after measurement. So definitely the definition by Griffiths is not completely correct. I came across about Rigged Hilbert space while searching in Stack but I am still not completely sure whether all physical states lie in Rigged Hilbert space or all states in Rigged Hilbert space are physical. So, my question is what are the necessary and sufficient conditions for a wavefunction to be physically possible?
 A: This is where the textbooks, in a way, lie to you. The operator $\hat{x}$ (and its counterpart, $\hat{p}$) is not a "good" quantum operator for a number of reasons, including the fact that these operators do not have normalizable eigenvectors, as you have seen. In particular,
$$|x\rangle$$
is not a sensible eigenvector as it is not normalizable. Rather, it just an "ideal point" of the space, a Hilbert-space analogue of $\infty$ in the real numbers (there's just a lot more of them), that makes it easy for us to locate a state in terms of a positional wave function by writing
$$|\psi\rangle = \int_{-\infty}^{\infty} [\psi_x(x)\ dx]\ |x\rangle$$
. Indeed, it would be better to write this as
$$|\psi\rangle = \int_{-\infty}^{\infty} [\psi_x(x)\ dx]\ ``|x\rangle"$$
with scaredy quotes!
And yes, this means that a particle cannot ever be localized perfectly to a single point in space. There is no such thing as a particle in state $|x\rangle$! In a way, this makes Galilean quantum mechanics not so different from its relativistic counterpart, relativistic quantum field theory or RQFT - the only difference is that there is no upper bound on the strength of localization permitted. (This should make physical sense when you realize GQM is just the $c \rightarrow \infty$ limit of RQFT; the details may change, but the paradigm cannot.) That is, GQM permits unbounded localization, not perfect localization.
But in neither case does this mean position is unmeasurable at all. Instead, we have to remember that all position measurements will only extract a finite amount of bits from the system. This, in turn, implies we are talking about localization to (certain, "good") subsets of space, $\mathbb{R}^3$ (in RQFT, it gets more complicated than this, because in principle, localization on a set still implies a sharp border, and we cannot do that either). Namely, while we cannot ever have either states where $x = x_0$ nor measurements asking if $x = x_0$, we can have states where $x \in S$ and measurements asking if $x \in S$, so long as $\mu(S) > 0$, where $\mu$ is the Lebesgue measure.
A way to formalize this that avoids overly-complicated mathematical constructs of the type required to use impossible things like $|x\rangle$ is to ditch the usual observables formalism in favor of an answer operator or projection operator formalism. In this case, if we are representing our vectors using the textbook "nonsense", i.e.
$$|\psi\rangle = \int_{-\infty}^{\infty} [\psi_x(x)\ dx]\ ``|x\rangle"$$
then we have a family of answer operators for position, of the form $\hat{A}(x \in S)$, which each mean "I heard that $x \in S$". The action of this thing on an honest quantum vector $|\psi\rangle$ then looks like
$$[\hat{A}(x \in S)]|\psi\rangle = \int_{-\infty}^{\infty} [\mathbf{1}_S(x)\ \psi_x(x)\ dx]\ ``|x\rangle"$$
In effect, we just change the positional wave function by multiplying by the indicator function $\mathbf{1}_S$ of the set $S$. You can see this is a projection because two applications leaves $|\psi\rangle$ unchanged, viz.
$$[\hat{A}(x \in S)]^2 = \hat{A}(x \in S)$$
And the meaning is that we are describing measurements by their "collapses" after they return a given result, here that the position $x$ was found to be within the set $S$, even if the measurement doesn't give it a number. These are, in effect, one-bit measurements or yes-no measurements. If one wants to take the subjective thesis regarding quantum states, where that $|\psi\rangle$ is the knowledge held by an agent regarding possible questions that can be asked about a system, the answer operator describes updating our agent's knowledge with a single bit of new information.
A: The problem with my question was I assumed that this below postulate of quantum mechanics (given in R. Shankar chapter 4 as 3rd postulate) to be literally true

If the particle is in a state $|\psi\rangle$, measurement of the variable (corresponding to) $\hat{\Omega}$ will yield one of the eigenvalues $\omega$ with probability
$P(\omega)\propto |\langle \omega|\psi\rangle|^2$. The state of the system will change from $|\psi\rangle$ to $|\omega\rangle$ as a result of the measurement.

In the comments others have noted that it is not exactly true in the case of continuous eigenstates. It is only approximately true in the sense that the wavefunction will be a continuous wave packet which resembles Dirac delta but is not exactly Dirac delta.
A: This answer is meant as a supplement to Valter Moretti's one.
Quantum systems are defined by their Hamiltonian, however, this is normally not their single observable. We have the basic observables stemming from the space-time context (coordinate, momentum, spin), plus the Hamiltonian, plus other observables stemming from other symmetries (orbital / total angular momentum, center of energy, Runge-Lenz etc.), all of them subject to various linear and non-linear relations (such as commutators).
As of such, because all observables are, each in turn, a self-adjoint operator, the set of admissible (physical) pure states is not the reunion of the self-adjointness domains of each observable (as subsets of the Hilbert space), but rather their intersection which is typically a proper subset of each self-adjointness domain and is made of continuous, differentiable functions.
For example, the free spinless Galilean particle in 1D has the fundamental observables coordinate, momentum, and Hamiltonian related by the Born-Jordan commutation relations for coordinate and momentum and the Hamiltonian defined as square of momentum. As of such, the set of physical realizable pure states is given by the intersection of the domain of all non-zero commutators between the operators. This is no longer a Sobolev space (made up of weakly differentiable functions), but a test function space, strongly differentiable (for example, one takes the Schwartz test function space).
A: If you want to use the theory of probability, a necessary condition for a wavefunction to be physically meanigful is $$\psi \in L^2(\mathbb{R}^3,d^3x)\:.$$ That is because, as a basic postulate of QM, we have that:
$\qquad\qquad\qquad\qquad$ $|\psi(x)|^2$ is the probability density to find the particle at $x$,
and the total probability must be $1$:
$$\int_{\mathbb{R}^3} |\psi(x)|^2 d^3x =1 <+\infty$$
(Values different from $1$ can be next obtained  by considering non-normalized wavefunctions).
That this condition is also sufficient is a much more delicate issue which largely depends on the physical hypotheses you assume on realizable pure states.
In principle all vectors
$\psi \in L^2(\mathbb{R}^3,d^3x)$ are admitted.
No continuity or differentiability requirements make sense, even if it is sometimes erroneously stated. That is because all observables, as another basic postulate of QM,  are self-adjoint operators and no differential operator is selfadjoint: in fact, one should deal with selfadjoint extensions of these differential operators, whose domains are made of non-differentiable functions, generally speaking.
Rigged Hilbert spaces, i.e., the rigorous version of Dirac (fantastic!) formalism elaborated by Gelfand and coworkers, has to be considered a mere formal/mathematical tool.
In particular distributions as $\delta(x-x')$ are not physically meaningful as they do not satisfy the condition to be elements of $L^2$.
A: In addition to what John Rennie said in the comments, I would like to highlight another thing using the quote you provided:

Physically realizable states correspond to the square-integrable
solutions to Schrödinger’s equation.

the delta function isn't a solution to Schrödinger’s equation.
a physical wavefunction therefore satisfies:
$$\left[-\frac{\hbar^2}{2m}\nabla^2+V(\vec{x})\right]\psi (\vec{x})=E\psi (\vec{x}),$$
And must be normalizeable:
$$\int_{-\infty}^{\infty}d^3x ~ \psi^{*}\psi <\infty$$
the delta functions $\delta(x-x') $ form a basis to the Hilbert space but they are not a basis of eigenfunctions of the Hamiltonian operator.
