To get better horizontal spacing of the \oset macro -- specifically, to make its spacing the same as that of a "relational operator" (which is the case for \to) -- you could encase the macro's definition in a \mathrel wrapper.
To make the \oset macro usable for different symbols/letters in the base and superscript positions, it's necessary to introduce a third, optional, argument: the argument of \vbox. Its default value, 0pt is suitable for single uppercase letters in the superscript position and arrows in the base position. For other combinations, you'll need to experiment a bit to find the suitable distance by which the superscript term should be raised; the values given in the example below may be OK for the selected math font (newpxmath). Different values will probably need to be chosen if you use a different math font.

\documentclass[11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs} % for '\midrule' macro
\usepackage{amsmath} % for '\overset' macro
\usepackage{newpxmath,newpxtext}
% new \oset macro:
\makeatletter
\newcommand{\oset}[3][0ex]{%
\mathrel{\mathop{#3}\limits^{
\vbox to#1{\kern-2\ex@
\hbox{$\scriptstyle#2$}\vss}}}}
\makeatother
\begin{document}
[
\begin{array}[t]{@{}c@{}}
\text{with \texttt{\string\overset}}\
\midrule
X_n\overset{P}{\to} X \
X_n\overset{D}{\to} X \
X_n\overset{j}{\to} X \
X_n\overset{\text{rth}}{\to} X \
X_n\overset{\text{i.i.d.}}{\sim} X
\end{array}
\qquad
\begin{array}[t]{@{}c@{}}
\text{with \texttt{\string\oset}}\
\midrule
X_n\oset{P}{\to} X \
X_n\oset{D}{\to} X \
X_n\oset[.35ex]{j}{\to} X \
X_n\oset[.45ex]{\text{rth}}{\to} X \
X_n\oset[.6ex]{\text{i.i.d.}}{\sim} X
\end{array}
]
\end{document}
Addendum, August 2022: I've received a request to explain how one would have to modify \oset to \uset, so as to place the supplemental material below rather than above the arrow. Here's how I think it should be done:
\makeatletter
\newcommand{\uset}[3][0ex]{%
\mathrel{\mathop{#3}\limits_{
\vbox to#1{\kern-7\ex@
\hbox{$\scriptstyle#2$}\vss}}}}
\makeatother
The definition of \uset contains 2 changes relative to the definition of \oset:
An additional remark: The material below the arrow is typeset in \scriptstyle math mode; that's fine for single letters or symbols. For longer expressions, such as i.i.d., you may want to reduce the font size a bit more. This may be done, say, by changing
X_n\uset{\textup{i.i.d.}}{\sim} X
to
X_n\uset{\textup{\tiny i.i.d.}}{\sim} X
I suppose this remark applies to both \uset and \oset. E.g., one may prefer the result of X_n\oset[.3ex]{\text{\tiny i.i.d.}}{\sim} X to that of X_n\oset[.6ex]{\text{i.i.d.}}{\sim} X.
vboxsize? – 1010011010 Aug 04 '14 at 18:29\toarrow looks off (i.e. horizontal spacing) also the font on the P is different. – bdeonovic Aug 04 '14 at 18:32\DeclarePairedDelimitercomes very close to what you want. – 1010011010 Aug 04 '14 at 18:38\mathrelis better suited. See @Mico's answer. – 1010011010 Aug 04 '14 at 18:49stackenginepackage, for setting either the gap or baseline shift between vertically offset objects. – Steven B. Segletes Aug 05 '14 at 09:50