Basicity is how well an atom can donate electrons. More is the electron density more is the basicity of the compound.
In Aniline the lone pair of electrons present on the nitrogen are involved in resonance, so the electron density on N is less than expected.
In compound II (Diphenylamine), since two benzene ring is present so the electron density will be less as now lone pair are involved in resonance of both the ring.
Thus electron density on Nitrogen is less than as compare to Nitrogen atom of Aniline
Similarly, in III compound (Triphenylamine), since three benzene ring is present the lone pair are more localized, and, thus electron density will be much less (least) as compared to the other compounds
In 4th structure, there is no resonance so, lone pair are present with nitrogen itself, and the electron density will be high, also due to inductive effect of the alkyl groups the electron density is more, and thus it can easily donate the electrons as compared to all other compounds. So the basicity is the highest for compound IV.
Therefore, the order of basicity is IV>I>II>III.