In most countries it's not legally possible. Countries like Malta or Gibraltar offer gambling/lottery licenses, same goes for the Isle of Man. But you have to consider that you can't just put together a bunch of scripts: it's regulated (keyword is player protection), quite complex and last but not least it is expensive, you have to get your software certified and so on - and the licenses aint cheap either. You need a very solid budget to pull that.
As an example, forming a company plus gambling license on the IOM costs a few hundred thousand EUR in total for the first (3?) years.. and it takes about 6 months minimum in total. Malta/Gibraltar's a bit cheaper, though, as far as I remember.
A few countries in South America offer licenses as well. It's cheaper and in some places there is actually like no regulations, no certifications needed or anything. So yeah, that might ease things. But then again, licenses from those countries have a very low reputation among players... because most of the scammers have their companies over there (big surprise). Keep in mind that you want the hardcore players, only a very few of the players are really interesting when it comes to making profits. And those guys can be picky. Still, you'll a few thousand bucks to set that up. And you should get some professional advice to make sure it won't bite you in the ass when it comes to taxes and laws.
Bottom line: not as easy as people might think, not really cheap... you should only do that step if you mean seriously business.