Where do you live? In Europe online casinos are regulated, and of course your money is (reasonably) safe on these regulated sites. But its common sense to not deposit all your retirement funds on a poker site, just as you would not deposit it in a village bank with no depositors ensurance. Poker sites like banks can go broke, but luckily it does not happen all that often.
If you live in the US outside the states, where online casinos are legal, then the situation is quite different. There are sites, that still accept US customers, but in principle there is always a risk, that US authorities might suddenly decide to go after these sites, as they did with Full Tilt, PokerStars and Absolute Poker back in 2011. So in that situation your funds are fairly unsafe, and maybe its best to just accept the laws of the place, where you live, even you dont agree with them.