Yes, it is possible (depending on your circumstances and DM)
Nothing in the rules prevents this
There is nothing in the rules for resting that prescribes the environment that you can rest in. There are only certain things that interrupt rest according to the rules:
If the rest is interrupted by a period of strenuous activity - at least 1 hour of walking, fighting, casting spells, or similar adventuring activity - the characters must begin the rest again to gain any benefit from it.
Thus, if it is safe and you can breathe you should be able to rest according to the rules alone.
However, you DM might have other concerns about resting and sleeping under water that are not covered by the rules.
Environmental conditions might make sleep tricky for most races1
Short rests just involve a short period of respite. A long rest involves sleep though (for most races). Unlike rest, there are no rules about sleeping or what can disturb it so a DM must make some rulings. Breathing is obviously a good place to start when choosing a sleeping location, but there are also other considerations. How important these considerations are to you and your particular circumstances will be up to your DM.
Temperature: For example, water is often much cooler than body temperature. Trying to rest for long periods of time in cold water might be dangerous (hypothermia) and uncomfortable and might be ruled to prevent sleep for those reasons.
Moving water/buoyancy: In water, a human-like body is buoyant and trying to sleep on a surface under water could prove tricky you might have to tie yourself down to actually sleep on a surface. Also, not all water is still and could cause a lot of shifting (even dangerous amounts) that could affect sleep. Watch out for tides and currents! Think of it this way: laying on a pool on a inflatable raft is very easy to sleep on. You put that raft in a white water rapids and I'll bet sleep doesn't come as easy!
Most, if not all, of these seem overcomable in one way or another (especially with magic) and, over time, a character could learn to rest comfortably under water. And as a DM it seems like a fun thing to help a player do if they want and if it is relevant. A DM can may of course rule that, depending on the exact circumstances, that it is not possible to rest.
1 - This answer assumes a human-like, land-dwelling physiology obviously. Other races might have quirks that make it easier or harder to sleep underwater. For example, something like a water-dwelling triton would have no issue sleeping under water.